Session logged out too soon

蹲街弑〆低调 提交于 2019-12-01 21:28:47

I've finally found the root of this problem.

There is an issue with Identity in ASP.NET Core 2.1 whereby if you have implemented your own version of the UserStore but not IUserSecurityStampStore, most functionality regarding security stamps will be skipped.

When you call AddIdentity() it does a validation check on the securityStamp every 30 minutes.

This results in the confusing behaviour that the user is logged out after 30 minutes, even though the cookies did not expire.

There is a fix for this coming in ASP.NET Core 2.2 apparently, further details here

https://github.com/aspnet/Identity/issues/1880

In the meantime, you can either get your UserStore to implement IUserSecurityStampStore, or do what I did as a quick fix for now, by adding this to your startup.cs which increases the time between failures from 30 minutes to 10 hours.

services.Configure(o => o.ValidationInterval = TimeSpan.FromHours(10));

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!