.NET后台 cookie简单存取中文乱码

 HttpCookie objCookie = new HttpCookie("SubID", SubID);
                        HttpCookie objCookie02 = new HttpCookie("SubName", HttpUtility.UrlEncode(SubName));
                        Response.Cookies.Add(objCookie);
                        Response.Cookies.Add(objCookie02);

SubID = Convert.ToInt32(Request.Cookies["SubID"].Value);
                SubName = HttpUtility.UrlDecode(Request.Cookies["SubName"].Value);
                SubID = SubID == 0 ? 1 : SubID;
                SubName = SubName == "" ? "郑州" : SubName;

 

posted @ 2020-01-04 14:01  离。  阅读(25)  评论(0编辑  收藏