标签:
今天在做项目的时候遇到了读取cookie的值出现乱码的情况
解决方法如下:
设置cookie 的值:
HttpCookie cookie = new HttpCookie("cookiename", System.Web.HttpContext.Current.Server.UrlEncode("anyben"));
Response.Cookies.Add(cookie);
Response.Cookies["cookiename"].Expires = DateTime.Now.AddHours(3);
读取cookie的值:
string cookiename = System.Web.HttpContext.Current.Server.UrlDecode(Request.Cookies["cookiename"].Value);
标签:
原文地址:http://www.cnblogs.com/anyben/p/4287344.html