Asp.net deleting project files/folders IIS restart, Session loss issues

Source: Internet
Author: User

After careful consideration, the ticket returned by SSO is also different, and the original IIS is restarted. The final solution is as follows:

Create a class that inherits the IHttpModule
Copy codeThe Code is 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 Module configuration in Web. Config.
Copy codeThe Code is as follows:
<! -- Solve IIS restart caused by deleting project files/folders -->
<Add name = "stopAppDomainRestartOnFolderDelete" type = "DeployAssistant. Facade. Web. StopAppDomainRestartOnFolderDeleteModule, DeployAssistant. Facade"/>

In this way, the AppDomain of the file/folder will not be restarted and the Session will not be lost. The world has become better!

PS: changes in the Web. Config and bin folders will still restart the Web, which must be retained!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.