[英]HttpContext.Current is null
我正在使用以下代码删除特定的cookie。 但现在不起作用。 错误HttpContext.Current为null。 我猜不出为什么现在发生了。 请澄清一下。
if (HttpContext.Current.Request.Cookies[name] != null{
HttpContext.Current.Request.Cookies.Remove(name);
}
请帮我解决这个问题。
尝试这个。
HttpCookieCollection MyCookieCollection = Request.Cookies;
HttpCookie MyCookie = MyCookieCollection.Get(name);
if ( MyCookie != null)
{
HttpContext.Current.Request.Cookies.Remove(name);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.