littlecharva
littlecharva

Reputation: 4244

ASP.NET In Proc Session State

We have an MVC web app that uses FormsAuthentication and also stores a couple of variables in Session variables. We've encountered a few situations lately where the session variables are lost, but the user is still logged in. A quick Google lead me to a few SO articles mentioning that In Proc Session State is regularly lost and that if we require it to persist, we should consider moving to a non In Proc solution.

Coming from a classic ASP background, where we relied on Session state for the lifetime of the session, it seems a bit baffling that I now can't rely on it at all. Surely In Proc Session State is of no value to anyone if it can be lost at the drop of a hat? Am I missing something?

I realise that storing it in an SQL server has it's benefits, but for small webapps with little traffic, In Proc is an ideal solution, could it be relied upon.

Upvotes: 1

Views: 2049

Answers (2)

ASetty
ASetty

Reputation: 114

ASP.NET session state is able to run in a separate process from the ASP.NET host process. If session state is in a separate process, the ASP.NET process can come and go while the session state process remains available. Of course, you can still use session state in process similar to classic ASP, too.

You don’t have to use SQL server to store session data in out of process, you can use out of process state server which can be in memory on the same server as the web server.

You can read more about how to configure out of process session state under http://msdn.microsoft.com/en-us/library/ms972429.aspx

Upvotes: 1

x2.
x2.

Reputation: 9668

As far as i know in-proc sessions state is lost after recompiling application and recycling application pool. App pool could be recycled if there is not enough memory or it's have regular restart time interval.

Upvotes: 1

Related Questions