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!