關於.NET HttpCookie 中文亂碼問題
阿新 • • 發佈:2017-05-19
sys esp value 解碼 enc default logs tostring system
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 = Shop.Split(‘,‘);
關於.NET HttpCookie 中文亂碼問題