[英]ASP.Net Core 2.0 SignOutAsync deleting the wrong Cookie?
i have a ASP.net Core 2.0 MVC Application and experiencing a weird problem. 我有一个ASP.net Core 2.0 MVC应用程序,遇到了一个奇怪的问题。 When using HttpContext.SignInAsync(...) to SignIn a User in my AccountsControler.cs this creates a Cookie named ".AspNetCore.Identity.Application".
在我的AccountsControler.cs中使用HttpContext.SignInAsync(...)登录用户时,这将创建一个名为“ .AspNetCore.Identity.Application”的Cookie。 When later using HttpContext.SignOutAsync () to sign out the user, ASP.net Core decides to delete the cookie name "Identity.External" by setting this Cookie in the Response-Header to expire at the unix epoch.
稍后使用HttpContext.SignOutAsync()登出用户时,ASP.net Core决定通过在Response-Header中将此Cookie设置为在unix时代过期来删除cookie名称“ Identity.External”。
Looks like i got something wrong with my CookieAuthentication. 好像我的CookieAuthentication出了点问题。 Anybody got an idea, where to look?
有人知道,去哪里找?
FunFact: Neither of both names is what i expected to see, since i configured a completely diffrent name for CookieAuthentication: FunFact:这两个名称都不是我希望看到的,因为我为CookieAuthentication配置了完全不同的名称:
services.AddAuthentication (CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie (
options => {
options.Cookie.Name = "MyMagic.User";
}
);
Actually the problem seemed to be, that i used 其实问题似乎是我用过的
service.AddAuthentication(...)
in this App. 在这个应用程序中。 Looks like a ASP.net Core 1.0 migration artefact in my code.
在我的代码中看起来像是ASP.net Core 1.0迁移工件。
After removing the explicit Cookie-Authentication, SignInAsync() and SignOutAsync() used the same cookie name. 删除显式Cookie身份验证后, SignInAsync()和SignOutAsync()使用相同的Cookie名称。
Additionally, with 此外,
services.ConfigureApplicationCookie(opts => {
opts.Cookie.Name = "My.Cookie.User";
});
i was able to rename the cookie. 我能够重命名cookie。 :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.