Session timeout in ASP.NET

后端 未结 15 2164
忘了有多久
忘了有多久 2020-11-22 09:14

I am running an ASP.NET 2.0 application in IIS 6.0. I want session timeout to be 60 minutes rather than the default 20 minutes. I have done the following

  1. Set <
相关标签:
15条回答
  • 2020-11-22 09:32

    Use the following code block in your web.config file. Here default session time out is 80 mins.

    <system.web>
     <sessionState mode="InProc" cookieless="false" timeout="80" />
    </system.web>
    

    Use the following link for Session Timeout with popup alert message.

    Session Timeout Example

    FYI:The above examples is done with devexpress popup control so you need to customize/replace devexpress popup control with normal popup control. If your using devexpress no need to customize

    0 讨论(0)
  • 2020-11-22 09:33

    I don't know about web.config or IIS. But I believe that from C# code you can do it like

    Session.Timeout = 60; // 60 is number of minutes
    
    0 讨论(0)
  • 2020-11-22 09:34

    if you are want session timeout for website than remove

    <authentication mode="Forms">
          <forms timeout="50"/>
    </authentication>
    

    tag from web.config file.

    0 讨论(0)
  • 2020-11-22 09:39

    Are you using Forms authentication?

    Forms authentication uses it own value for timeout (30 min. by default). A forms authentication timeout will send the user to the login page with the session still active. This may look like the behavior your app gives when session times out making it easy to confuse one with the other.

    <system.web>
        <authentication mode="Forms">
              <forms timeout="50"/>
        </authentication>
    
        <sessionState timeout="60"  />
    </system.web>
    

    Setting the forms timeout to something less than the session timeout can give the user a window in which to log back in without losing any session data.

    0 讨论(0)
  • 2020-11-22 09:41

    The default session timeout is defined into IIS to 20 minutes

    Follow the procedures below for each site hosted on the IIS 8.5 web

    Open the IIS 8.5 Manager.

    Click the site name.

    Select "Configuration Editor" under the "Management" section.

    From the "Section:" drop-down list at the top of the configuration editor, locate "system.web/sessionState".

    Set the "timeout" to "00:20:00 or less”, using the lowest value possible depending upon the application. Acceptable values are 5 minutes for high-value applications, 10 minutes for medium-value applications, and 20 minutes for low-value applications.

    In the "Actions" pane, click "Apply".

    0 讨论(0)
  • 2020-11-22 09:42

    In my situation, it was Application Pool. It is set to restart when idle for xx mins. When I set it to not restart, it seems to use value from Web Config.

    0 讨论(0)
提交回复
热议问题