ASP.NET loses session data when delete directory on WebApplications

a 夏天 提交于 2019-12-08 02:54:06

问题


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:


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



来源:https://stackoverflow.com/questions/5803493/asp-net-loses-session-data-when-delete-directory-on-webapplications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!