Cookies ending too fast in ASP.NET Core

I have an ASP.NET Core 1.1.2 project in which I use cookie authentication. I have a problem where users are prompted to return to the system after a downtime for an hour or less and lose their jobs. The code below is what I use in the Configure function in Startup.cs to set this and from what I can say, it should expire after 8 hours. BTW, ProjectProcessFlow is just the name of the project.

  app.UseCookieAuthentication(new CookieAuthenticationOptions()
  {
    AuthenticationScheme = "ProjectProcessFlow",
    LoginPath = new PathString("/Account/Login/"),       
    ExpireTimeSpan = new TimeSpan(8, 0, 0),
    SlidingExpiration = true,
    AutomaticAuthenticate = true,
    AutomaticChallenge = true
  });

I turn on Microsoft.AspNetCore.Authentication.Cookies v1.1.2 in NuGet. What do I need to do to expire login at the expected time?

Additional Information:

I found that when a timeout occurred and the user was prompted to log in again, a warning was found in the event viewer on the server that he could not find the log folder within the project. So I created this folder and waited for the timeout to happen again. When this happened, a log file was created in this folder containing the following:

Hosting environment: Production
Content root path: C:\inetpub\wwwroot\Sprout
Now listening on: http://localhost:13423
Application started. Press Ctrl+C to shut down.

When I repeated this process, the same thing happened, except that after "localhost:" a different number appeared. I should mention that the project name is ProjectProcessFlow, but the URL ends with Sprout.

+8
source share
3 answers

, .

, .

, , - - 20 . IIS 20 ( - Linux).

, - (0 ) ping 5 , Monitis.

enter image description here

+4

.AddIdentity ConfigureServices?

            services.AddIdentity<ApplicationUser, IdentityRole>(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<ApplicationDbContext>().AddDefaultTokenProviders();

cookie ASP.NET MVC

+1

, , . IIS 20 20 ASP.NET cookie ( ). , ConfigureServices Startup

services.AddDataProtection()
                .PersistKeysToFileSystem(new System.IO.DirectoryInfo("SOME WHERE IN STORAGE"))
                //.ProtectKeysWithCertificate(new X509Certificate2());
                .SetDefaultKeyLifetime(TimeSpan.FromDays(90));

. DataProtection

+1

All Articles