惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
V
V2EX
雷峰网
雷峰网
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
F
Full Disclosure
Y
Y Combinator Blog
V
V2EX - 技术
Attack and Defense Labs
Attack and Defense Labs
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
SecWiki News
SecWiki News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
量子位
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
K
Kaspersky official blog
B
Blog
A
Arctic Wolf
Hacker News: Ask HN
Hacker News: Ask HN
L
LangChain Blog
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
Recent Announcements
Recent Announcements
宝玉的分享
宝玉的分享
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
Lohrmann on Cybersecurity
D
Docker
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
S
Security Affairs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - 小罗

学习CRYPTO C#中使用网络函数 (第一部分 用户函数)[翻译] C#图片处理类 在WINCE或Mobile下面获取当前目录 (翻译)从底层了解ASP.NET体系结构 采用HttpModules来重写URLs 使用会话状态(一) 小技巧:ASP.NET中编程杀死进程 - 小罗 - 博客园 ASP.NET—From验证:全部代码及讲解 ASP.NET如何存取 SQLServer数据库图片 ASP.NET基本编程习惯 用asp.net还原与恢复sqlserver数据库 ASP.NET 2.0移动开发之定义设备筛选器 Session丢失原因与解决方案小结 C# 文件操作(上传 下载 删除 文件列表...) 40 种网页技巧 过滤ASP.NET输出HTML中的无用空格 在ASP.NET中创建安全的web站点(配置) ASP.NET Forums 页面模型分析
小心!目录删除及重命名操作,一定丢失Session~~
小罗 · 2008-01-19 · via 博客园 - 小罗

如果你发现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的内部机制对待目录有点像个守财奴,它死守着目录,你创建它不会管(往里加),一但创建他就会监视该目录,若你要删除或重命名它的(动它的目录),它就发生重起了。