首页 > 代码库 > 关于.NET HttpCookie 中文乱码问题

关于.NET HttpCookie 中文乱码问题


                HttpCookie Cookie = new HttpCookie("Shop");

                //服务端存入Cookie前先进行编码
                Cookie.Values.Add(ShopId,HttpUtility.UrlEncode(ShopInformation, System.Text.Encoding.Default));
                Cookie.Expires = DateTime.Now.AddMinutes(20);
                Response.Cookies.Add(Cookie);

 

                     //客户端读取 按编码的格式进行解码

                    var Shop = Request.Cookies["Shop"][Key].ToString();
                    Shop = HttpUtility.UrlDecode(Shop,System.Text.Encoding.Default);
                    var ShopData = http://www.mamicode.com/Shop.Split(‘,‘);

         技术分享 

关于.NET HttpCookie 中文乱码问题