Tips/Trick : Session timeout problem in IIS7


Hi all,

Recently we did release to a staging environment running IIS7.x, .NET 3.5. after few days of release users get problem of session timeout when user leave the pc for an hour or more than that. So I have started to search for the cause.

Looked into the session timeout settings in web.config of the application. we already set timeout to 180 minutes (3 hour). So I have tested it myself & came to know that user session get expires after 20 minutes (which is the default setting).

So I started looking into the IIS settings and came to know that i missed two things to change :

  1. Application pool’s Idle Time-out(minutes)
  2. Session state – State server’s Time-out (seconds)

Once I have changed above settings than after Session timeout worked.

So after that I have made one checklist that can help us to validate Session timeout settings, here i am sharing it with you as well so that you will also get some benefits from it :

  1. Application Pool – Advanced Settings Menu – Process Model – Idle Time-out (minutes)
  2. Sites – Session State – Cookie Settings – Time-out (minutes)
  3. If you are using State Server or SQL Server to manage your session (instead of InProcess), Here is the steps to follow :       Sites – Session State – Session State Mode Settings – Time-out (seconds)
  4. Under Web.config – system.web – authentication mode – forms – timeout (for form authentication)

That is all , no more things you need to set in order to increase session timeout from its default value.

Simple but very useful tips.

Hope this will help !!!

Jay Ganesh

Advertisements

2 thoughts on “Tips/Trick : Session timeout problem in IIS7

  1. Hi Jay Ganesh,

    The above solution helps lot. But still i’ve issue in Session Timeout on IIS 7. Below i given the web.config file details. Here my issue is our web app is running perfectly in IIS 6 without session timeout issue. After migrating code to II7, we are experiencing session timeout in 13 mins. And this session time out is not consistent. But its happening after 10 Min of Idle time.

    I followed the steps you given above. I set the App Pool to 20 mins and my expectation for time out also after 20 min of idle timeout.

    Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
    –>

    <!—->
    <!—->

    <!–
    The section enables configuration
    of the security authentication mode used by
    ASP.NET to identify an incoming user.
    –>

    <!–
    The section enables configuration
    of what to do if/when an unhandled error occurs
    during the execution of a request. Specifically,
    it enables developers to configure html error pages
    to be displayed in place of a error stack trace.

    –>
    <!–
    requestEncoding Specifies the assumed encoding of each incoming request, including
    posted data and the query string. If the request comes with a request header
    containing an Accept-Charset attribute, it overrides the requestEncoding in
    configuration. The default encoding is UTF-8, specified in the
    tag included in the Machine.config file created when the .NET Framework is
    installed. If request encoding is not specified in a Machine.config or Web.config
    file, encoding defaults to the computer’s Regional Options locale setting.
    In single-server applications, requestEncoding and responseEncoding should be
    the same. For the less common case (multiple-server applications where the default
    server encodings are different), you can vary the request and response encoding
    using local Web.config files.

    responseEncoding Specifies the content encoding of responses. The default encoding
    is UTF-8, specified in the tag included in the Machine.config file
    created when the .NET Framework is installed. If response encoding is not specified
    in a Machine.config or Web.config file, encoding defaults to the computer’s Regional
    Options locale setting. In single-server applications, requestEncoding and responseEncoding
    should be the same. For the less common case (multiple-server applications where the
    default server encodings are different), you can vary the request and response
    encoding using local Web.config files.

    fileEncoding Specifies the default encoding for .aspx, .asmx, and .asax file
    parsing. Unicode and UTF-8 files saved with the byte order mark prefix will be
    automatically recognized regardless of the value of fileEncoding.

    –>

    Please let me know how to resolve this issue..

  2. hi i m using wcf service application, i m using net.tcp binding but every time when i run application it shows http url rather than net.tcp

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s