asp.net中文cookie的乱码问题

来源:互联网 发布:知牛财经 直播地址 编辑:程序博客网 时间:2024/06/11 09:48
中文cookie的问题,
在Windows 2000正常,
在Windows 2003 sp1下会偶尔出现乱码(遇到双字节特殊字符时候,例子:「`蹆绌),
在windows 2003 SP2下基本乱码

解决办法:
采用
Server.UrlEncode();
Server.UrlDecode();
Cookie["MyCookie"] = Server.UrlEncode("中文")
Response.Write(Server.UrlDecode(Request.Cookies("MyCookie").Value()))
编码和解码。


另外编码和解码要一致
System.Web.HttpUtility.UrlDecode 和 System.Web.HttpUtility.UrlEncode
System.Web.HttpContext.Current.Server.UrlDecode 和 System.Web.HttpContext.Current.Server.UrlEncode

说明:
http://support.microsoft.com/default.aspx?scid=kb;en-us;313282
[最后修改由 admin, 于 2007-06-28 17:19:58]
 
原创粉丝点击