日期:2014-05-20  浏览次数:20371 次

asp.net写入Cookie,ASP读取时乱码。编码已经指定为BG2312
asp.net写入Cookie,ASP读取时乱码。编码已经指定为BG2312

Response.Cookies[ "YuanlinUser "][ "Sex "]   =   HttpUtility.UrlDecode(s,System.Text.Encoding.GetEncoding( "GB2312 "));


如果把ASP页面编码设为UTf-8则显示正常


极度郁闷中.................

谢谢

------解决方案--------------------
你直接 输出呢
不使用 任何编码.
Response.Cookies[ "YuanlinUser "][ "Sex "] = s;
------解决方案--------------------
直接输出
就把web.config配置gb2312去掉

------解决方案--------------------
Web.Config文件中按以下配置
<globalization requestEncoding= "gb2312 " responseEncoding= "gb2312 "/>
------解决方案--------------------
up
------解决方案--------------------
樓主是否可考慮不對Cookies進行編碼呢?!

我印象裡,Cookies統一采用utf-8編碼,所以你用GB2312會亂碼。
實事如何,沒有去考證。^_^
------解决方案--------------------
Response.Cookies[ "YuanlinUser "][ "Sex "] = HttpUtility.UrlDecode(s,System.Text.Encoding.GetEncoding( "utf-8 "));

默认情况下是用utf-8写入cookies的,读的时候当然也要用utf-8解码.用其它解码当然是乱码了.
------解决方案--------------------
原来还有BG2312的啊?= =
------解决方案--------------------
楼主在asp里面是怎么输出的?asp页面的编码是什么?

------解决方案--------------------
试验环境
config
<globalization requestEncoding= "gb2312 " responseEncoding= "gb2312 "/>

asp 为 ansi,其它不要指定