【发布时间】:2019-04-10 18:30:10
【问题描述】:
是否有可能根据 OwinMiddleware 中的 cookie 名称删除 cookie?
我知道 IOwinContext 有自己的基于 Set-Cookie Header 的 cookie 抽象,而 HttpContext 有自己的 HttpCookieCollection。在我的中间件中,我无法访问 HttpContext,因此无法设置:Response.Cookies["userId"].Expires = DateTime.Now.AddDays(-1);
使用 IOwinContext 我尝试执行以下操作:
Context.Response.Cookies.Delete("userId");
Context.Response.Cookies.Append("userId", "");
但它不起作用。
有任何可行的示例如何实现我的目标? 非常感谢您的帮助和提示。
【问题讨论】:
标签: c# asp.net-mvc cookies owin middleware