WebForm - cookie赋值乱码问题
cookie的值为中文时候,取cookie的值会出现乱码
解决办法:存取cookie时候先解码和编码
存cookie,进行编码:
cookie.Value = HttpUtility.UrlEncode("上海");
取cookie时候,进行解码: cookieValue = HttpUtility.UrlDecode(cookie.Value);
HttpContext.Current.Response.Cookies["LoginUser"].Value = HttpUtility.UrlEncode(tUser.UserName);
string LoginUser = HttpUtility.UrlDecode(Request.Cookies["LoginUser"].Value);