Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session empty in ASP.NET / IIS after rebuild

I'm working on an ASP.NET MVC web application and I've made my own authentication module, which is session-based (no cookies). The problem is: When I rebuild my application, I'm automatically logged of (session is empty).

Normally this is not a big problem because my application is not 'automatically' rebuilding in a production environment. But I've also made a module that changes the resource-files and after a modification of a resource file, the application seems to rebuild automatically.

So my actual question: Is it possible to 'keep' the session variables/stay logged on after a rebuild?

like image 877
Jeff Maes Avatar asked Feb 19 '10 12:02

Jeff Maes


2 Answers

You'll need to use something other than InProc sessions. You'll need to look at using either ASP.net State Server, or a SQL server as the backing store for your sessions. These can be a bit slower, but are more resilient.

like image 139
Paddy Avatar answered Sep 20 '22 17:09

Paddy


As Paddy notes, you will need to use something other than InProc sessions. Go to MSDN to see how to change to either a SQL or Windows Service based solution.

Actually I think it is good practice to always use out-of-proc sessions. The performance hit when using the ASP.NET State Service on the same box is minimal and you won't experience any nasty surprises if you decide to change the Session State mechanism at some point in the future (while running InProc you can shove anything in the Session, but once you use out-of-proc session state, the data has to be serializable, which may come as a nasty surprise at a time when surprises are not welcome).

like image 22
Rune Avatar answered Sep 19 '22 17:09

Rune