locked
SessionState Timeout question, pls help! RRS feed

  • Question

  • User2021079516 posted

    I have this setting in the web.config file: <sessionState timeout="540" />. This tries to make all the sessions expires after 8 hours. However, the session expires much faster than that and I got an object reference not set to an instance of an object error. Could some tell me if there is something else affects the session?

    Thanks in advance! 

     

     

    Wednesday, May 20, 2009 3:27 PM

Answers

  • User854688209 posted
    #Software: Microsoft Internet Information Services 6.0
    #Version: 1.0
    #Date: 2009-01-30 02:05:59
    #Fields: date time s-sitename s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status  <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    These are the resaons which to get above info in iis:

    1. Restart the web site
    2. Restart the IIS server
    3. When new log files get created
    4. Logging Configuration Changes

    Please mark the post as answer if your issue has been resolved. So that other can refer for similar kind of issue.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 22, 2009 1:36 AM

All replies

  • User-1460838308 posted
    Go to IIS and set Session timeout there as well
    Wednesday, May 20, 2009 5:21 PM
  • User533502567 posted

    You have to increase session timeout in IIS in addition to webconfig settings.

     Here are some other reasons for Session loss..

    1.) IIS worker process restart or Application Pool recycle.(Check the System logs)

    2.) Application Domain restart due to Antivirus scans or changes in Config files.

    Wednesday, May 20, 2009 10:52 PM
  • User-151352204 posted

     once u try with above code

    <sessionState mode="InProc" stateConnectionString="tcpip=72.41.47.186:42424" cookieless="false" timeout="1440"/>

    in web.config file


    or

    u set session timeout in IIS

    Thursday, May 21, 2009 1:59 AM
  • User854688209 posted

    check slidingExpiration in webconfigit should be true

    <authentication mode="Forms">
         <forms name="userAuthentication" loginUrl="/Login.aspx"
           enableCrossAppRedirects="true" path="/" domain="" slidingExpiration="true" timeout="30" />
     </authentication>

    Changing of web.config, global.asax and files in bin directory will cause the restart of application pool.

    Thursday, May 21, 2009 2:27 AM
  • User2021079516 posted

    Thanks for everyone's help! However I am little bit confused here. I tried to increase the IIS session timeout but it doesn't help. I did some testing:

    1.  Go to IIS then Default Web Site
    2.  Go to the properties of the virtual directory of the web site
    3. Click the Configuration button and then Options tab, I checked Enable session state and changed the Session timeout to 5 minutes <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
    4. Save the changes and restart IIS 
    5. The session tiemout is still 540 in my web.config file
    6. I reload my web site and did something and let the site sit there more than 5 minutes, then do postback but I didn't get session is null error.
    <o:p></o:p> 

    It looks like that the Session tiemout in IIS has no control or I went to a wrong place to change it?

     

    <o:p></o:p>  For this setting on the web.config file<o:p></o:p><authentication mode="Forms">
         <forms name="userAuthentication" loginUrl="/Login.aspx"
           enableCrossAppRedirects="true" path="/" domain="" slidingExpiration="true" timeout="30" />
     </authentication> 

     

    <o:p></o:p>I don't have login page and the authentication mode is windows. Will the slidingExpiration="true" still work?

     

    <o:p></o:p>Thanks again for your help!<o:p></o:p>

     

    Thursday, May 21, 2009 9:51 AM
  • User533502567 posted

    Click the Configuration button and then Options tab, I checked Enable session state and changed the Session timeout to 5 minutes

    Are you running under IIS or Visualstudio development server?

    Thursday, May 21, 2009 11:03 AM
  • User2021079516 posted

    I tested it under IIS.

    Thanks! 

     

    Thursday, May 21, 2009 11:22 AM
  • User854688209 posted

    Do you have below entry in IIS log files?

    The location of IIS log files is below

    Windows Xp:
    C:\WINDOWS\system32\Logfiles\W3SVC1

    Windows NT/2000:
    C:\WINNT\system32\Logfiles\W3SVC1

    #Software: Microsoft Internet Information Services 6.0
    #Version: 1.0
    #Date: 2009-05-21 01:47:01
    #Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status

    If yes what is the time duration between two entries.

    Thursday, May 21, 2009 11:38 AM
  • User533502567 posted

  • The session tiemout is still 540 in my web.config file
  • I reload my web site and did something and let the site sit there more than 5 minutes, then do postback but I didn't get session is null error.

Webconfig session timeout value overrides IIS value. Here are some reasons for Session loss..

1.) IIS worker process restart or Application Pool recycle.(Check the System logs)

2.) Application Domain restart due to Antivirus scans or changes in Config files.

Use Debug Diagnostics to find the problem..

http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1286

or

http://www.microsoft.com/downloads/details.aspx?familyid=9BFA49BC-376B-4A54-95AA-73C9156706E7&displaylang=en

Thursday, May 21, 2009 11:45 AM
  • User166505692 posted

    Are you killing Session any where in your application,, if so check is that event getting fired   which is removing the session.

     

     

    Thursday, May 21, 2009 12:04 PM
  • User2021079516 posted

    Now I think the Session expired because the IIS was reset or the application pool was recycled  by other developers since the server (testing server) hosts different web sites. Other question - where I can find the log file to check if the IIS restart or the pool recycled.

    Thanks! 

  • The session tiemout is still 540 in my web.config file
  • I reload my web site and did something and let the site sit there more than 5 minutes, then do postback but I didn't get session is null error.
  • Webconfig session timeout value overrides IIS value. Here are some reasons for Session loss..

    1.) IIS worker process restart or Application Pool recycle.(Check the System logs)

    2.) Application Domain restart due to Antivirus scans or changes in Config files.

    Use Debug Diagnostics to find the problem..

    http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1286

    or

    http://www.microsoft.com/downloads/details.aspx?familyid=9BFA49BC-376B-4A54-95AA-73C9156706E7&displaylang=en

    Thursday, May 21, 2009 12:26 PM
  • User2021079516 posted

    Yes, I can find the file. The time duration is either 1 second or a few minutes b/t two entries.

    Do you have below entry in IIS log files?

    The location of IIS log files is below

    Windows Xp:
    C:\WINDOWS\system32\Logfiles\W3SVC1

    Windows NT/2000:
    C:\WINNT\system32\Logfiles\W3SVC1

    #Software: Microsoft Internet Information Services 6.0
    #Version: 1.0
    #Date: 2009-05-21 01:47:01
    #Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status

    If yes what is the time duration between two entries.

    Thursday, May 21, 2009 12:30 PM
  • User854688209 posted

    1. Open logfiles again and check the last entry, keep a note of last entry, now restart the IIS and check log file again.

    2. Open logfiles again and check the last entry, keep a note of last entry, now recycle the application pool and check the log file again.

    Thursday, May 21, 2009 12:49 PM
  • User2021079516 posted

    Now I found the resetting IIS cause the session expired in my case. I checked the system event log and it has these:

    The World Wide Web Publishing Service service was successfully sent a stop control.

    The World Wide Web Publishing Service service was successfully sent a start control.

    Since it is on testing server and our project is under testing, we should not have this issue (hopefully) when it is moved to prod server. 

    Thanks to everyone for your help!

    Thursday, May 21, 2009 3:55 PM
  • User854688209 posted
    #Software: Microsoft Internet Information Services 6.0
    #Version: 1.0
    #Date: 2009-01-30 02:05:59
    #Fields: date time s-sitename s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status  <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    These are the resaons which to get above info in iis:

    1. Restart the web site
    2. Restart the IIS server
    3. When new log files get created
    4. Logging Configuration Changes

    Please mark the post as answer if your issue has been resolved. So that other can refer for similar kind of issue.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 22, 2009 1:36 AM
  • User956004986 posted

    Respectfully - nobody has mentioned this. In my limited experience, this is always the reason that sessions timeout...

    IIS - Application pool - Advanced settings - Idle timeout

    It's always 20 minutes by default. Set it to something longer than your session timeout.

    Thursday, February 28, 2013 6:04 PM
  • User-1338060929 posted

    Chek your IIS configuration time out setting & if it is ok then your data base pool is fiull with temp data or having any poblem with you db server which is restart befor your time out so session problem is exist

    Thursday, March 7, 2013 10:25 AM