简体   繁体   中英

ASP.NET web app sessions issue

I developed an ASP.NET web application that is installed on a "live" IIS 7.5. The web app uses http sessions to pass parameters between pages for logged in users. This works great on my development machine (tested with local IIS in VS2010 IDE), but when this web app is uploaded to a client's IIS and they start using it (Google Chrome and IE browsers), at some random moments the session variables seem to disappear. My first guess was to increase the session timeout setting via web.config file by adding this line:

<configuration>
 <system.web>
  <sessionState timeout="20"></sessionState>
 </system.web>
</configuration>

But that doesn't seem to fix the issue. So it made me wonder, what other settings are there concerning sessions? Something like an internal folder that keeps a cache of all sessions that gets overflown on an actual IIS? Any ideas?

EDIT : Following @wy__'s suggestion, I modified the web.config file and started seeing the same issue on my dev machine. Here's the whole system.web section as I have it now:

  <system.web>
    <compilation targetFramework="4.0" debug="false"/>
    <pages validateRequest="false"/>
    <httpRuntime requestValidationMode="2.0" executionTimeout="110" maxRequestLength="262144"/>
    <sessionState timeout="20" cookieless="true" regenerateExpiredSessionId="true"></sessionState>
  </system.web>

I also checked and there's only one w3wp.exe process running.

By default, the session uses cookies to track user sessions. If you are not sure whether users turn them off or not, you can configuring cookieless session.

ie

<configuration>
    <system.web>
        <sessionState cookieless="true" regenerateExpiredSessionId="true" />
    </system.web>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM