Authentication 基于OWIN cookie的认证中间件可以';不要更改cookie名称

Authentication 基于OWIN cookie的认证中间件可以';不要更改cookie名称,authentication,cookies,owin,owin-middleware,Authentication,Cookies,Owin,Owin Middleware,我正在尝试通过执行以下操作重命名身份验证cookie: app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/account/login"), CookieSecure = CookieSecureOption.S

我正在尝试通过执行以下操作重命名身份验证cookie:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/account/login"),
    CookieSecure = CookieSecureOption.SameAsRequest,
    SlidingExpiration = false,
    CookieName = "mycookiename"
});

当我从IIS Express运行应用程序并在Fiddler中检查cookie名称时,cookie名称按预期设置为“mycokiename”。但是,当我部署站点时,cookie名称仍然设置为“.AspNet.applicationcokie”。在如何让这一变化发挥作用方面,我有什么遗漏吗?IIS中是否存在可以覆盖我的应用程序设置的内容?

IIS在会话状态下有自己的会话配置。您可以尝试将以下内容放入web.config:

<sessionState cookieless="UseCookies" cookieName="mycookiename" mode="InProc" useHostingIdentity="true" />


有关更多信息,请访问MSDN网站:

这将设置会话cookie而不是身份验证cookie。