Add Name= "Stopappdomainrestartonfolderdelete"
Type= "Mywebsite.stopappdomainrestartonfolderdeletemodule"/>
It should be noted that "Stopappdomainrestartonfolderdelete" is a custom name, "Mywebsite" is a namespace in the above. cs file, typically the project name. " Stopappdomainrestartonfolderdeletemodule "is the class name in the above. cs file.
That's it. This will prevent the folder from being deleted AppDomain reboot, but will still reboot when modifying the web.config and Bin folders, which is exactly what we want.
But the deletion of several files will find that the session will still expire, why is this so? It's not clear yet ... So the search on the Internet has the following way
Configure the session to be saved under <system.web> as StateServer.
<sessionstate mode= "StateServer" statenetworktimeout= "20"
stateconnectionstring= "tcpip=127.0.0.1:42424"/>
Using System.Reflection;
using System.Web;
Namespace Mywebsite
{
///<summary>
///stops tutorial the ASP tutorial. NET AppDomain being restarted (which C Lears
///Session state, cache etc.) whenever a folder is deleted.
///</summary>
public class Stopappdomainrestartonfolderdeletemodule:ihttpmodule
{
public void Init (HttpApplication context)
{
PropertyInfo p = typeof (HttpRuntime). GetProperty ("FileChangesMonitor",
Bi Ndingflags.nonpublic | BindingFlags.Public | BindingFlags.Static);
Object o = p.getvalue (null, NULL);
FieldInfo f = o.gettype (). GetField ("_dirmonsubdirs",
BindingFlags.Instance | bindingflags.nonpublic | Bindingflags.ignorecase);
Object monitor = F.getvalue (o);
MethodInfo m = Monitor.gettype (). GetMethod ("stopmonitoring",
BindingFlags.Instance | bindingflags.nonpublic) ;
M.invoke (monitor, new object[] {});
}
public void Dispose () {}
}
}