Cookie Authentication expiring too soon in ASP.NET Core

后端 未结 3 750
自闭症患者
自闭症患者 2020-12-01 17:16

I have a ASP.NET Core 1.1.2 project in which I am using cookie authentication. I am having a problem where users are being prompted to log back in after being idle for an h

3条回答
  •  粉色の甜心
    2020-12-01 17:34

    Do you have services.AddIdentity set up in your ConfigureServices method?

                services.AddIdentity(config =>
            {               
                //  Require a confirmed email in order to log in
                config.SignIn.RequireConfirmedEmail = true;
                // Cookie settings
                config.Cookies.ApplicationCookie.ExpireTimeSpan = TimeSpan.FromHours(10);
                config.Cookies.ApplicationCookie.LoginPath = "/Account/LogIn";
                config.Cookies.ApplicationCookie.LogoutPath = "/Account/LogOut";
            }).AddEntityFrameworkStores().AddDefaultTokenProviders();
    

    I had a similar issue and resolved it here ASP.NET MVC Core Identity & Cookies

提交回复
热议问题