开发者

Preserve Session Variables in Web Application After Build

Every time I build my web application, my session variables are lost from before the build. Is there anyway to prese开发者_运维问答rve session variables during the build?


Session variables are by default held in memory by the web server. When you build, you are resetting the application, and hence losing all session (and static, cache, etc) values.

If you wish, you can configure ASP.NET to use a different session state provider by changing the session state mode. Note "InProc" is the default, which holds them all in memory. You can use StateServer which runs in a different process and can be on a different machine, or SQLServer - or even write your own.


Every time you rebuild, the server obviously is going to restart and nuke all your session data, so it depends on what you are trying to accomplish.

If you are talking about simple user session data then try storing them in cookies (for development purposes) but if you are using .NET's caching to store more extensive session data then this becomes more complex then it might be worth.


Remember that every time you rebuild, you are potentially redefining the meaning of each Session variable. ASP.NET has no way to know whether or not it has the same meaning after the build.

It's generally not worthwhile to even think about keeping them around. In certain circumstances (testing), then maybe you should write a test page to populate the variables, then launch you into the page you're testing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜