2

Comecei a utilizar o Identity no ASP.NET MVC e percebi que a página fica dando vários requests, mesmo sem o usuário executar nenhuma ação. Me parece que isso é para validar os cookies, estou certo? Se sim, tem como aumentar o tempo entre esses requests? Pelo que percebi, a cada 6 segundos ele faz um novo request.

1
  • Que tipo de requests? Em desenvolvimento, o ASP.NET MVC envia para a sua página um recurso chamado Browser Link, que faz o VS se comunicar com a página gerada. Seria disso que estamos falando? 1/09/2016 às 14:53

1 Resposta 1

1

No arquivo Startup.Auth.cs, adicione as opções para configura-las:

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

        });
}

É só mudar o tempo da propriedade ExpireTimeSpan para um tempo que considere adequado.

Da documentação:

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.

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .