0

I have a project that I created with asp.net core. In this project,

HttpContext.SignInAsync(),

I import my user. My problem is that the timeout I gave to delete the cookie in local works properly, but when it starts working on the server, it sends login again within 5 minutes when I do not take action. When I spoke to the hosting bought server authorities, IIS applications were allowed 5 minutes and if no action was taken, the server would go to sleep. I keep going back to login. How can I extend this period or help if I keep sending requests so that the server does not shut down?

You need ideas or information to solve this problem. They didn't do a try

Login service

   claims.Add(new Claim(ClaimTypes.NameIdentifier, result.Id.ToString()));

                var claimsIdentity = new ClaimsIdentity(
                    claims, CookieAuthenticationDefaults.AuthenticationScheme);

                var authProperties = new AuthenticationProperties
                {
                    IsPersistent = /*dto.RememberMe*/ true,
                };
               
              await HttpContext.SignInAsync(
                    CookieAuthenticationDefaults.AuthenticationScheme,
                    new ClaimsPrincipal(claimsIdentity),
                    authProperties);

                return role;
            }

Startup.cs

    services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(opt => {
            opt.Cookie.Name = "";
            opt.ExpireTimeSpan = TimeSpan.FromSeconds(99999);
                opt.Cookie.IsEssential = true;
                opt.ReturnUrlParameter = "/Account/SignIn";
                opt.LogoutPath = "/Account/SignIn";
                opt.LoginPath = "/Account/SignIn";
                opt.AccessDeniedPath= "/Account/SignIn";
            });


Stefan Wuebbe
  • 2,109
  • 5
  • 17
  • 28
Kocagozz
  • 13
  • 3
  • 1
    You can set IIS `idle time-out`. Please check the [`official document for more details`](https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-85/idle-worker-process-page-out-in-iis85#configure-idle-worker-process-page-out-as-a-default-for-application-pools). – Md Farid Uddin Kiron Dec 30 '22 at 09:34
  • https://stackoverflow.com/questions/781357/how-do-i-set-up-my-iis-to-keep-my-application-alive – MichaelMao Dec 30 '22 at 09:39
  • In IIS, Select your Application, Under, ApplicationDevelopment tab, select `SessionState` then Scroll down, and you would get `cookie settings`, Mode dropdown should select as `use cookies` and set your expected `time-out`. You can [`check the reference here`](https://i.stack.imgur.com/KrZT9.png) – Md Farid Uddin Kiron Dec 30 '22 at 09:59

0 Answers0