我正在 asp.net mvc2 中创建一个 Web 应用程序,并且在一个有趣的情况下遇到了一个小问题,我认为这是 Web 应用程序的默认行为。 (sessionstate= inproc)
当我删除 web 应用程序根目录中的目录时,我的会话数据将被清除。
我已经阅读了寻求解决方案的人的一些问题,但对问题的了解不多,有人知道如何防止这种行为吗?
注意: 我不想移动 IIS 的其他实例提供的其他“子域”的目录,也不想更改 sqlserver 的会话状态
提前感谢您的帮助。
谢谢大家,在该文章的链接上找到了解决方案。
我在我的 global.asax Application_Start 上添加了以下代码:
Dim p As System.Reflection.PropertyInfo = GetType(HttpRuntime).GetProperty("FileChangesMonitor", Reflection.BindingFlags.Public Or Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Static)
Dim o As Object = p.GetValue(Nothing, Nothing)
Dim f As System.Reflection.FieldInfo = o.GetType.GetField("_dirMonSubdirs", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.IgnoreCase)
Dim monitor As Object = f.GetValue(o)
Dim m As System.Reflection.MethodInfo = monitor.GetType.GetMethod("StopMonitoring", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)
m.Invoke(monitor, New Object() {})
谢谢。
http://dotnetslackers.com/Community/blogs/haissam/archive/2008/11/12/disable-session-expiration-when-using-directory-delete.aspx
I'm creating a web application in asp.net mvc2 and I'm having a little problem in an interesting situation that I assume is a default behaviour on webapplications. (sessionstate= inproc)
When i delete a directory inside the webapplication root Directory, my session data is cleaned.
I've read some questions from people asking for a solution, but not much about the problem, does anyone know how to prevent this behaviour?
Note: I don't want to move directory for other "subdomain" served by other instance of IIS, and don't want to change sessionstate for sqlserver
Thanks in advance for your help.
THANKS GUYS, FOUND THE SOLUTION SOMEWHERE ON A LINK OF THAT ARTICLE.
i've added on my global.asax Application_Start the folowing code:
Dim p As System.Reflection.PropertyInfo = GetType(HttpRuntime).GetProperty("FileChangesMonitor", Reflection.BindingFlags.Public Or Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Static)
Dim o As Object = p.GetValue(Nothing, Nothing)
Dim f As System.Reflection.FieldInfo = o.GetType.GetField("_dirMonSubdirs", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.IgnoreCase)
Dim monitor As Object = f.GetValue(o)
Dim m As System.Reflection.MethodInfo = monitor.GetType.GetMethod("StopMonitoring", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)
m.Invoke(monitor, New Object() {})
THANKS.
http://dotnetslackers.com/Community/blogs/haissam/archive/2008/11/12/disable-session-expiration-when-using-directory-delete.aspx
发布评论
评论(1)
最有可能与此相关: ASP.NET 删除目录结果在应用程序重新启动中。
这篇博文可能会为您澄清一些事情:在 ASP.net 2.0 中删除目录
我的建议是创建一个虚拟目录并操作该目录的内容(而不是触摸应用程序目录本身)。
Most likely relates to this one: ASP.NET Deleting a directory results in application restart.
this blog post might clarify things a bit for you: Deleting Directory in ASP.net 2.0
My suggestion would be to create a virtual directory and manipulate the contents of that directory (instead of touching app directory itself).