Asp.net Identity with many request without client actions

Asked

Viewed 54 times

2

I started using Identity in ASP.NET MVC and I realized that the page keeps giving several requests, even without the user performing any action. It seems to me that this is to validate the cookies, am I right? If yes, have to increase the time between these requests? From what I understand, every six seconds he makes a new request.

  • What kind of requests? In development, ASP.NET MVC sends to your page a resource called Browser Link, that makes VS communicate with the generated page. That’s what we’re talking about?

1 answer

1

In the archive Startup.Auth.cs, 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 timing of the property ExpireTimeSpan for a time which it deems appropriate.

Of 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 a request which is more than Halfway through the expiration window.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.