关于Cookies的问题!为什么不能提前判断是否为NULL呢?
关于Cookies的问题!为什么不能提前判断是否为NULL呢?
if (HttpContext.Current.Request.Cookies["city"].Value == null)
{
HttpContext.Current.Response.Cookies["city"].Value = System.Web.HttpUtility.UrlEncode(city);
HttpContext.Current.Response.Cookies["city"].Expires = DateTime.MaxValue;
HttpContext.Current.Response.Write("<script>top.window.location.href='pg.pg'</script>");
HttpContext.Current.Response.End();
}
else
{
.....加入Cookies....
}
为什么会提示错误呢?
如果在判断前面就加COOKIES值!就没问题!
但是如果这样的话就不能保存上次更改的COOKIES了
应该怎么解决