0

I have it set to 120 minutes but it doesn't last that long. I am not sure exactly how long it does last but I know it isn't 2 hrs.

<sessionState timeout="120" />

This was set only in the default Web.config and NOT in the one in the Views directory nor the Web.Debug.config or Web.Release.config.

Would that make a difference as the default session timeout is 20 min?

4
  • 2
    Your application pool recycling would kill the sessions too. Commented Dec 20, 2012 at 19:02
  • @JonathanWood session state is generally not recommended for ASP.NET - do you have some more information on this? Commented Dec 20, 2012 at 19:03
  • @Darren - How can I tell if the application pool is killing the session? Commented Dec 20, 2012 at 19:08
  • @JonathanWood - Are you saying that there should be a static variable for the "Customer Number" of the currently signed in customer, as opposed to using the SessionState ? I know it's been .. quite awhile since you posted that, but is that still the case? Commented May 29, 2014 at 19:17

2 Answers 2

1

To guarantee your sessions don't get killed by a w3wp.exe crash or an application pool recycle, you should move the session state to a separate store. The easiest is the ASP.Net State Server service. Make sure to start the service on the host machine and add this to your web.config instead:

<sessionState mode="StateServer"
    stateConnectionString="tcpip=SampleStateServer:42424"
    cookieless="false"
    timeout="120"/>
Sign up to request clarification or add additional context in comments.

2 Comments

I will have to talk to my network admin about this. I'm only the developer.
@MB34: It can also be done with a SQL server. Keep in mind, that anything you put into session this way must implement the Serializable attribute.
0

I think you should define the session state mode

There are there different session states in ASP.NET http://msdn.microsoft.com/en-us/library/ms178586(v=VS.80).aspx

In-Process Mode The defaul one is <sessionState mode="InProc" timeout="10" />, the session will be clear after rebuild the project

State Server Mode we can use this, but remember to turn the services - ASP.NET State Service

<sessionState mode="StateServer"
  stateConnectionString="tcpip=localhost:42424"
  sqlConnectionString="data source=.\SQLEXPRESS; User ID=sa;Password=12345678; Integrated Security=SSPI"
  cookieless="false"
  timeout="2"
/>

SQL Server Mode we can use this after create a DB ASPSate by command, pls check this site for details - http://www.brianstevenson.com/blog/aspstate-concurrently-running-for-net-1011-and-net-20

<sessionState mode="SQLServer"
  stateConnectionString="tcpip=localhost:63586"
  sqlConnectionString="data source=.\SQLEXPRESS; User ID=sa;Password=12345678; Integrated Security=SSPI"
  cookieless="false"
  timeout="2"
/>

The session in State Server Mode & SQL Server Mode will not be cleared after rebuild the project, it's good for development

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.