views:

28

answers:

2

Hello,

I would like to know if there is a way to keep the session going.

I've got sick of losing my session between rebuilds/builds, if I change too much in my project or submit code to our SVN (tortoise via VisualSVN). I'm developing an ASP.NET MVC project with lots of jQuery.

I would like to do this as I test my project on one screen with Firefox (Firebug wins) and edit on the other in visual studio. As my project has a session system and I would like to be able to develop without having to keep re-logging into my system.

Thanks

Edit: Visual Studio 2008 Professional with the build in IIS development server. Windows Vista Business 64bit

+1  A: 

I don't think that's possible, given that the application restarts on each build. What you could do though, is add a temporary jQuery post call to the login page, that will run on startup.

$(function() {
    $.post('/login/', { username: 'phil', password: 'noonewillguessthis' });
});

That way you'll be logged on to the system "automatically" each time the page loads. Just remember to remove it before you deploy live... ;)

Tomas Lycken
I'll have to accept a small hack then. Will mark as the answer if someone can provide a less hackish approach ;)
Phil
+1  A: 

It is not possible, when you rebuild and change the content of your libraries they have to be reloaded into the process space. However, in .Net you can never remove assemblies from an AppDomain once they are loaded. To reload your library the AppDomain needs to be unloaded and loaded again. In addition, if there are any changes to your web.config, it will also unload/reload your AppDomain.

You could use something like pushing session state to SQL server so that the AppDomain recycle doesn't impact you. You can do this with the sessionState element of the web.config file.

Peter Oehlert
Thanks for the idea about SQL server will be something I will investigate but Tomas's solution works for now.
Phil
This actually works better. Just changed from the JS method and I don't loose my place in the application between restarts ! :)
Phil