views:

167

answers:

2

Hi,

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?

+5  A: 

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.

Paddy
Thank you. Found some more information about it: http://support.microsoft.com/kb/317604
Jeff Maes
This link helped my out: http://www.brianstevenson.com/blog/aspstate-concurrently-running-for-net-1011-and-net-20/
Jeff Maes
+1  A: 

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).

Rune