The program I developed under the file system was configured under IIS, and there were some problems with cookies.
1. The loss of cookies. I wrote an essay a few days ago "A very difficult problem. A web program developed under the file system mechanism using vs2005 cannot run normally if it is configured to iis?" "" recorded my solution to the problem of losing cookies that store super administrator permissions. Although the problem was finally solved, I didn't understand the reason. At the end of the essay, I gave a far-fetched reason why it works normally under the file system but not under iis: the file system provides a micro-server every time it is debugged, and memory is reallocated every time. The first time you run it under iis is to allocate memory. As long as the program does not change and does not need to be recompiled, the memory will no longer be reallocated. Today I saw the "Collection of Frequently Asked Questions about Using Session in ASP.NET" mentioned here: It may be related to the environment of the machine, such as firewall or anti-virus software, etc. Try turning off the firewall (the reason for losing Session should be related to the reason for losing cookies) Same). I think what he said makes sense. Running under the file system should not go through the firewall, but running under iis must go through the firewall. It seems I'm not the only one experiencing this problem. I have never encountered any loss of cookies or sessions when using asp.net1.1 before.
2. The Chinese characters in the cookies were garbled. I suddenly discovered last night that there was another problem with the Chinese characters in the cookies under IIS, showing garbled characters.
It took a long time to solve it:
//When writing cookies
string t =HttpUtility.UrlEncode (Chinese value to be written to cookies);
HttpCookie c = new HttpCookie("user_realname", t);
Response.Cookies.Add(c);
//When reading cookies
t=The obtained Chinese cookie value;
t = HttpUtility.UrlDecode(teacher_name);
That's it.
Remind friends who are using the vs2005 file system to develop projects to pay attention.
The reason for the difference in the operation of the file system and iis should be related to their operating mechanisms. I hope to find some information introducing their operating mechanisms!