您很有可能会获得仍然有效的旧身份验证票证,或者获得本地运行的另一个站点的身份验证票证。我会清除浏览器缓存和Cookie并再次运行。
另外,请尝试更改Cookie的名称,默认情况下将其设置为.AspNet.Cookies
,如果您在本地运行多个应用程序,则可能导致问题。前一阵子让我抓狂。
Cookie名称可以这样更改
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<UserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(0),
regenerateIdentity: (manager, user) => manager.GenerateUserIdentityAsync(user))
},
CookieName = "myAuthCookie",
});
可以在此处找到有关它的MSDN文档。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句