locked
redirect to login page after session timeout RRS feed

  • Question

  • User-309523270 posted

    Hi,

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

    Startup.cs

    public void 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]
    public class InventoryController : BaseController
    {

    }

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

    Thanks,

    tinac99

    Monday, November 4, 2019 5:25 PM

All replies