cookie|cookies| Chinese | Chinese garbled
I developed the program under the file system, configured to IIS, cookies out of some problems.
The loss of 1,cookies
I was in the last few days of the essay "very difficult problem, using VS2005 in the file system mechanism developed under the Web program, configured to IIS can not run correctly?" "I've solved the problem of losing cookies to store Super Administrator privileges, but I didn't understand why, although the problem was finally resolved." Essay finally I gave a reason to be normal under the file system, not normal under IIS: The file system provides a micro-server every time it is debugged, allocating memory every time. In IIS, the first run is to allocate memory, as long as the program does not make changes, without recompiling, it will no longer reallocate memory. Today, I saw the use of Session FAQ in asp.net: It may be related to the environment of the machine, such as firewall or anti-virus software, try to shut down the firewall (the reason for losing the session should be the same as the reason for the loss of cookies). Think he said there is a reason, in the file system run should not go through the firewall, under IIS running will pass the firewall. It seems that I have not been the only one who has encountered this problem. I did not encounter any loss of cookies or sessions when I used asp.net1.1 before.
2,cookies's Chinese garbled
I suddenly discovered last night that the Chinese in the cookies under IIS appeared to be in trouble, displaying garbled characters.
It took a while to solve:
When writing cookies
String T =httputility.urlencode (to be written to the Chinese value of the cookie);
HttpCookie C = new HttpCookie ("User_realname", t);
RESPONSE.COOKIES.ADD (c);
When reading cookies
T= the value of the Chinese cookies obtained;
t = Httputility.urldecode (teacher_name);
That's the solution.
Remind friends who are using the VS2005 file System development project to notice.
The reason why the file system and IIS run a difference should be related to their operating mechanism, hoping to find some information about their operating mechanism to see!