0

Possible Duplicate:
What happens when I edit web.config?

I have a login on my website that stores the user information into sessions. One issue however is that whenever I run or publish my applications it requires me to log in again. I test my applications frequently and I was wondering if this is common for sessions to clear everytime the application is run or published.

Thanks, Paul

Community
  • 1
  • 1
Paul
  • 429
  • 1
  • 5
  • 15
  • Take a look at this answer on SO: http://stackoverflow.com/questions/613824/how-to-prevent-an-asp-net-application-restarting-when-the-web-config-is-modified/629876#629876 – Ta01 Aug 25 '11 at 17:21
  • This isn't an exact duplicate as far as I can tell. There is a solution here specific to sessions. In that case run a session state server which is in memory but out of process and I believe won't restart when an app change occurs. – Adam Tuliper Aug 25 '11 at 18:11

2 Answers2

6

When you deploy new code, the application is recycled on the server. Ergo, all new sessions are created and the application_start methods etc in global asax are also invoked again.

If you want to 'stay logged in' regardless of session, you probably need to make some form of auto-login with a cookie on your machine.

Tejs
  • 40,736
  • 10
  • 68
  • 86
  • Thank you both. I think your both correct about the issue. I just found that there are 4 methods of session state managements. By default it uses InProc, which gets clears on deployment. I think I need to change this to a different method – Paul Aug 25 '11 at 17:30
4

When you build or deploy an application, the bin folder is updated. This causes the application to restart, so all sessions are lost.

Hans Kesting
  • 38,117
  • 9
  • 79
  • 111