Search code examples
asp.net-coreasp.net-identityblazor-server-side

I need to extend the Session Expiry Timeout/ Login Expiry Timeout in ASP.NET Core Blazor Server


I am developing a Blazor Server ASP.net core app. It has Cookie based authentication using RevalidatingIdentityAuthenticationStateProvider. When I login I find '.AspNetCore.Identity.Application' Cookie in my browser.

The problem I am facing is that I want to expend Session Expiry Timeout/Login Expiry Timeout and I am unable to do so.

Right Now Situation: After 30 min of my login when I refresh the page it redirects to the login screen which shows that the session has been expired.
What I want: I want that either the session does not expire or expires after a really long time.

Help will be appreciated !


Solution

  • Configure cookie expiration settings in startup:

    services.ConfigureApplicationCookie(ops =>
    {
        ops.ExpireTimeSpan = TimeSpan.FromMinutes(30);
        ops.SlidingExpiration = true;
    });