[英]How to remove cookie in Hosted environment, which i works in local environment?
我將AngularJS作為前端使用Web api,我在本地環境中開發了一個應用程序,並且在本地一切正常。 但是今天我不得不將我的應用程序托管在服務器上,突然我無法刪除可以在本地執行的cookie:
public virtual HttpResponseMessage UnAuthenticate()
{
if (HttpContext.Current.Request.Cookies["sessionId"] != null)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies["sessionId"];
cookie.Expires = DateTime.Now.AddDays(-1);
HttpContext.Current.Response.Cookies.Add(cookie);
}
HttpRuntime.Cache.Remove("cacheToken");
return null;
}
我究竟做錯了什么?
更新
它可以在IE中使用,但不能在Chrome中使用。
嘗試這個
public virtual HttpResponseMessage UnAuthenticate()
{
HttpCookie cookie = HttpContext.Current.Response.Cookies["sessionId"];
if (cookie != null)
{
cookie.Expires = DateTime.Now.AddDays(-1);
}
return null;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.