时间:2021-07-01 10:21:17 帮助过:44人阅读
HttpCookie cookie = new HttpCookie("name", System.Web.HttpContext.Current.Server.UrlEncode("脚本之家"));
Response.Cookies.Add(cookie);读取Cookie时:
if (Request.Cookies["name"] != null)
{
Response.Write(System.Web.HttpContext.Current.Server.UrlDecode(Request.Cookies["name"].Value));
}
注意:编码和解码要一致
代码如下:
System.Web.HttpContext.Current.Server.UrlDecode 和 System.Web.HttpContext.Current.Server.UrlEncode
System.Web.HttpUtility.UrlDecode 和 System.Web.HttpUtility.UrlEncode