hazjack
hazjack

Reputation: 1715

(ASP.NET MVC5) How to change default time out of 5 mins?

I have a web app developed with ASPNET MVC5 in which authentication is done by IdentityServer3 using OpenIdConnect (IdP is configured to use Google+).

The issue is that, my session is always timed out after 5 mins even I set cookie & session to 60 mins.

Below is the code:

This code is on Startup of the client

app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = "Cookies",
            SlidingExpiration = true,
            CookieName = "RefManWeb",
            ExpireTimeSpan = TimeSpan.FromHours(1),
        });

Also I have sessionState set in Web.config

<sessionState timeout="60"></sessionState>

Can you guy point out what is wrong here ? Any advice is much appriciated !

Update: all cookies have exprires = "At end of session".

enter image description here

Upvotes: 2

Views: 1052

Answers (1)

Marek
Marek

Reputation: 87

SlidingExpiration only works with option UseTokenLifetime = false in your OpenID middleware.

for e.g.

 app.UseOpenIdConnectAuthentication( new OpenIdConnectAuthenticationOptions()
            {
                Authority = options.AuthorityUrl.ToString(),
                ClientId = options.Client.Id.ToString(),
                RedirectUri = options.Client.Url.ToString(),
                PostLogoutRedirectUri = options.Client.Url.ToString(),
                ResponseType = "id_token",
                UseTokenLifetime = false,
                SignInAsAuthenticationType = options.CookieName,
                Notifications = new CustomNotificationProvider()
            });

Upvotes: 1

Related Questions