日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

發布時間:2025/7/14 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 小心!目录删除及重命名操作 ,一定丢失Session~~! 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

????
如果你發現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?
------?

{
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的內部機制對待目錄有點像個守財奴,它死守著目錄,你創建它不會管(往里加),一但創建他就會監視該目錄,若你要刪除或重命名它的(動它的目錄),它就發生重起了。。

轉載于:https://www.cnblogs.com/qqcrazyer/archive/2007/01/27/632075.html

總結

以上是生活随笔為你收集整理的小心!目录删除及重命名操作 ,一定丢失Session~~!的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。