[英]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.