Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

redirect to login page after session timeout

$
0
0

Hi,

I have set up the application to not be usable after a session time out:

Startup.cs

publicvoid ConfigureServices(IServiceCollection services)
{
     services = configureMiniProfiler(services);
     services.Configure<CookiePolicyOptions>(options =>
         {
               // This lambda determines whether user consent for non-essential cookies is needed for a given request.
       
options.CheckConsentNeeded = context =>true;
       
options.MinimumSameSitePolicy = SameSiteMode.None;
         });

      services.AddMvc()
                 .AddSessionStateTempDataProvider();

      services.AddSession(options =>
                   {
                          options.IdleTimeout = TimeSpan.FromSeconds(10);
                          options.Cookie.HttpOnly =true;
            
options.Cookie.Name =".ToolsAppSession";
          });

 services.ConfigureApplicationCookie(options =>
                 {
                        // Cookie settings
           
options.Cookie.HttpOnly =true;
           
options.ExpireTimeSpan = TimeSpan.FromSeconds(20);
                       options.LoginPath ="/Account/Login";
           
options.LogoutPath ="/Account/Login";
           
options.AccessDeniedPath ="/Account/AccessDenied";
           
options.SlidingExpiration =true;
          
options.Cookie.Name =".ToolsApp";
         
});

}

When the session time reaches expire time, any requests after that submits to the controller and hangs.

[Authorize]
publicclassInventoryController : BaseController
{

}

Is there a way I can redirect to login page after time out or on the request after time out?

Thanks,

tinac99


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>