删除 WebApplications 上的目录时 ASP.NET 丢失会话数据

发布于 2024-11-03 11:11:46 字数 1371 浏览 0 评论 0 原文

我正在 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

[浮城] 2024-11-10 11:11:46

最有可能与此相关: 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文