ASP.NET mvc auth or session expires quicker than set

后端 未结 2 1703
耶瑟儿~
耶瑟儿~ 2021-01-25 06:16

In my ASP.NET MVC5 website the login and session timeout in web.config are as follows:


  
    

        
2条回答
  •  忘了有多久
    2021-01-25 06:36

    First of all, try setting session timeout on Session_Start method inside Global.asax:

    void Session_Start(object sender, EventArgs e)
    {
        Session.Timeout = 60;
    }
    

    Note: By using in-process session state, your sessions will wiped out every IIS application pool recycles, which in your issue app pool recycled after 5 minutes.

    If above attempt doesn't work and you have access to server's IIS management, do these steps:

    1. Open IIS Manager.
    2. Select Application Pools => [your app pool name] => Recycling/Advanced Settings.
    3. Enable Regular time interval (minutes) and set it to 60, then apply your changes.

    If you don't have access on both IIS Manager & SQL Server configurations, you might want to try DB-based session state management instead of InProc mode (see MSDN reference below).

    DB-based session state requires changing mode attribute to SQLServer, e.g.:

    
        
    
    

    Reference:

    MSDN: https://msdn.microsoft.com/en-us/library/ms178586.aspx

    Session expires too quickly in asp.net mvc4 application

提交回复
热议问题