| 作者:未知 来源:网上收集 发布时间:2007-3-24 2:16:26 |
|
如果你发现session突然无理由的丢失,而当你认真的检查代码并且排除其它常规可能丢失 现在和大家分享下:希望对碰到类似钉子的朋友有用。。 说白了session丢失实质就是:应用程序重起! 应用程序什么时候自动重起呢? 请参考:Anand在dotnetindia.com发表的文章 原文引用 This talks about both 1.0 and 1.1 This behaviour has been bugging lots of people. ASP.Net will restart its application for various reasons. All these reasons are legitimate, but the side effect is that the application will reset all its cache, application state, and InProc session states. For worker process restart, ASP.NET will write an entry in the eventlog to eXPlain why (logLevel in controls how often eventlog is written). For application restart, however, in v1 and v1.1 there is no easy way for a customer to figure out why a restart happened. So by listing all reasons for app restart, I hope I can help some customers to understand and avoid the restart. For v1 - The max compilation limit is reached (look for numRecompilesBeforeApprestart in machine.config) - Physical application path of the web application has changed. - Change in global.asax or one of the included files - Change in machine.config - Change in web.config in the app root - Change inside bin Directory or its subdirs - A directory is renamed to bin, or bin is created - Overwhelming change notifications – too many files are changed too fast in one of content directories – could happen if, for example, files are generated on the fly per request - Change in the code-Access security policy file - The settings of various attributes in in machine.config affect the restart/shutdown of the worker process itself. However, if you use Windows 2003, and (by default) you are NOT using IIS5 isolation mode, is ignored. Instead, the settings in "Application Pools" in IIS manager is used.
{ - Any directory under the web application folder is renamed
如果避免不了这种操作(如:重命名目录);这里我们可以用cookie存信息或存到数据库去; 注意:除了以上列出的英文条件外。目录的删除操作一定丢失session。asp.net的内部机制对待目录有点像个守财奴,它死守着目录,你创建它不会管(往里加),一但创建他就会监视该目录,若你要删除或重命名它的(动它的目录),它就发生重起了。 |
| [返回上一页] [打 印] |
|
上一篇文章:mssql默认不区分大小写;向excel中写入长整型时异常 | 下一篇文章:Oracle的翻页Sql语句 |