LingSteven avatar image
0 Votes"
LingSteven asked ChaoDeng-MSFT edited

The session state is timeout in seconds, instead of minuntes

My webform application is deployed and hosted in IIS.

I set 120 for the timeout of session state in Web.config.

According to the document, the timeout is in minutes, but the session actually is timeout in 120 seconds. I did not understand this behavior. Do you konw the reason?

 <compilation defaultLanguage="c#" debug="true" targetFramework="4.5.2"/>
 <customErrors mode="Off"/>
 <authentication mode="Forms">
   <forms name="xxx" loginUrl="Error.aspx" protection="All" timeout="240"/>
   <deny users="?"/>
 <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
 <sessionState mode="InProc" cookieless="false" timeout="120"/>
 <globalization requestEncoding="Shift_JIS" responseEncoding="Shift_JIS" fileEncoding="Shift_JIS"/>
 <httpRuntime maxRequestLength="1048576" executionTimeout="1800"/>
 <xhtmlConformance mode="Legacy"/>
 <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ChaoDeng-MSFT avatar image
0 Votes"
ChaoDeng-MSFT answered ChaoDeng-MSFT edited

Hi @LingSteven ,
Session data for ASP.NET Web applications appears to be lost at random intervals for the InProc session state mode.


Session state data is lost if the AppDomain class or the Aspnet_wp.exe process (or the W3wp.exe process, for applications that run on IIS 7.0 or a later version) is recycled. Generally, the AppDomain is restarted based on several factors:

  • Various attributes (for example, the memoryLimit attribute) have particular settings in the <processModel> section of the configuration file.

  • The Global.asax or the Web.config file was modified.

  • The Bin directory of the Web application was modified.

  • Virus scanning software touched some .config files.

InProc session mode indicates that session state is stored locally. This means that with InProc session state mode is stored as life objects in the AppDomain of the Web application. This is why the session state is lost when Aspnet_wp.exe (or W3wp.exe, for applications that run on IIS) or the AppDomain restarts.

To work around this problem, you can use StateServer or SqlServer session state mode. ASP.NET provides these other approaches for storing session state data. In the StateServer and SqlServer modes, your session state is not stored in the AppDomain of the Web application.

For details, please read this article: Session-State Modes

If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best Regards,


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.