我正在使用下面的代碼來刪除特定的cookie。它的工作更早。但現在不行。出現錯誤HttpContext.Current爲空。我無法猜測爲什麼現在發生。請澄清我。HttpContext.Current爲空
if (HttpContext.Current.Request.Cookies[name] != null{
HttpContext.Current.Request.Cookies.Remove(name);
}
請幫我解決這個問題。
我正在使用下面的代碼來刪除特定的cookie。它的工作更早。但現在不行。出現錯誤HttpContext.Current爲空。我無法猜測爲什麼現在發生。請澄清我。HttpContext.Current爲空
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);
}
您是否在本地主機或外部IIS服務器上測試您的應用程序? – whoah
本地主機和服務器也 – user3085540
在本地主機和服務器得到了同樣的錯誤 – user3085540