分享
 
 
 

小心!目录删除及重命名操作,一定丢失Session~~

王朝other·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

如果你发现session突然无理由的丢失,而当你认真的检查代码并且排除其它常规可能丢失

的可能性时,你可能会像我一样,几乎要接近崩溃~!

后来发现问题出在我用代码创建一个临时目录然后删除临时目录的删除操作上。

现在和大家分享下:希望对碰到类似钉子的朋友有用。。

说白了session丢失实质就是:应用程序重起!

应用程序什么时候自动重起呢?

请参考:Anand在dotnetindia.com发表的文章

原文引用

{

Why ASP.NET Restarts?

Found this link from one of the blogs I was browsing today. This is ASP.NET Forum post by Patrick Y. Ng of MS.

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.

You can detect the restart of application and worker process by using the performance monitor. The counters to monitor are "ASP.NET\Application Restarts" and "ASP.NET\Worker Process Restarts".

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

------

'http://www.knowsky.com

{

Things that causes application restart:

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

For v1.1

--------

The list for v1.1 is the same as v1, with the following new conditions:

{

- User code called HttpRuntime.UnloadAppDomain

- Any directory under the web application folder is renamed

}

IIS 6.0

--------

If you're using IIS 6.0, and you're not using IIS 5 compatible mode, then aspnet_wp.exe will be replaced by w3svc.exe. You may want to go to IIS Manager, go to Application Pools/DefaultAppPool, and see if any of the parameters on the Recycling and Performance tabs are causing the IIS worker process (w3svc.exe) to shutdown.

}

也就是说 asp.net 会监视应用程序目录,一但有被监视

的动作发生(比如:修改了config、重命名目录等)应用程序就会自动重起

当然这时你的session一定丢失了。

如果避免不了这种操作(如:重命名目录);这里我们可以用cookie存信息或存到数据库去;

注意:除了以上列出的英文条件外。目录的删除操作一定丢失session。asp.net的内部机制对待目录有点像个守财奴,它死守着目录,你创建它不会管(往里加),一但创建他就会监视该目录,若你要删除或重命名它的(动它的目录),它就发生重起了。

http://www.cnblogs.com/qqcrazyer/archive/2007/01/27/632075.html

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有