Asp.net Identity with many request without client actions

2

I started using Identity in ASP.NET MVC and realized that the page is giving several requests , even without the user taking any action. It seems to me that this is to validate cookies, am I right? If so, can you increase the time between these requests ? From what I've noticed, every 6 seconds it makes a new request .

    
asked by anonymous 28.01.2016 / 14:47

1 answer

1

In the Startup.Auth.cs file, add the options to configure them:

public void ConfigureAuth(IAppBuilder app)
    {
        // Enable the application to use a cookie to store information for the signed in user
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
            ExpireTimeSpan = new System.TimeSpan(0,30,0),
            SlidingExpiration = true

        });
}

Just change the time from the ExpireTimeSpan property to a time it deems appropriate.

From the documentation:

  

ExpireTimeSpan:   Controls how much time the cookie will remain valid from the point it is created. The expiration information is in the protected cookie ticket. Because of that an expired cookie will be ignored even if it is passed to the server after the browser should have purged it

     

SlidingExpiration:   The SlidingExpiration is set to true to instruct the middleware to re-issue a new cookie with a new expiration time any time it processes which is more than halfway through the expiration window.

    
22.02.2016 / 21:13