u936293
u936293

Reputation: 16264

Authentication session timeout

I am using the built-in Identity framework offered by the MVC template in VS2013 .NET Framework 4.5.1.

I am using the feature more or less out of the box. It has been working fine. Compared to other posts I have read, my web.config has:

<authentication mode="None" />

How do I set a time out period for authenticated sessions, that is, after the user has logged in?

Upvotes: 5

Views: 3249

Answers (1)

Andre Pena
Andre Pena

Reputation: 59416

If you are using Owin authentication, you should have something like this on your StartUp.cs file within the App_Start folder:

public void ConfigureAuth(IAppBuilder app)
{
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        LoginPath = new PathString("/Account/Login"),
        // here you go
        ExpireTimeSpan = new TimeSpan(60000000000)
    });
    app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
}

Upvotes: 9

Related Questions