In a closer look, SSO returned ticket, only to find that the original IIS restarted, the final solution is as follows:
Create a new class to inherit IHttpModule
Copy Code code as follows:
<summary>
Stops the ASP.net AppDomain being restarted (which clears
Session state, Cache etc.) Whenever a folder is deleted.
</summary>
public class Stopappdomainrestartonfolderdeletemodule:ihttpmodule
{
private static bool Disablefcns = FALSE;
public void Init (HttpApplication context)
{
if (DISABLEFCNS) return;
PropertyInfo p = typeof (HttpRuntime). GetProperty ("FileChangesMonitor", BindingFlags.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[] {});
Disablefcns = true;
}
public void Dispose () {}
}
Then add the module configuration in Web.config
Copy Code code as follows:
<!--resolve IIS restart caused by deleting project files/Folders-->
<add name= "Stopappdomainrestartonfolderdelete" type= " Deployassistant.facade.web.stopappdomainrestartonfolderdeletemodule,deployassistant.facade "/>
So every time you delete the file/folder AppDomain will not restart, the session will not be lost. The world is getting better!
Changes under the PS:Web.Config and Bin folders will still allow the Web to restart, which must be preserved!