仔细一看,SSO返回的ticket也不相同,才发现原来IIS重启了,最后解决方案如下:
新建一个类继承IHttpModule
复制代码 代码如下:
/// <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() { }
}
随后在Web.Config中加入Module配置
复制代码 代码如下:
<!--解决删除项目文件/文件夹引起的IIS重启-->
<add name="stopAppDomainRestartOnFolderDelete" type="DeployAssistant.Facade.Web.StopAppDomainRestartOnFolderDeleteModule,DeployAssistant.Facade"/>
这样每次再删除文件/文件夹AppDomain都不会重启了,Session也不会丢失了。世界也变得更美好了!
PS:Web.Config和bin文件夹下的改动依然会让Web重启,这也是必须保留的!
新建一个类继承IHttpModule
复制代码 代码如下:
/// <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() { }
}
随后在Web.Config中加入Module配置
复制代码 代码如下:
<!--解决删除项目文件/文件夹引起的IIS重启-->
<add name="stopAppDomainRestartOnFolderDelete" type="DeployAssistant.Facade.Web.StopAppDomainRestartOnFolderDeleteModule,DeployAssistant.Facade"/>
这样每次再删除文件/文件夹AppDomain都不会重启了,Session也不会丢失了。世界也变得更美好了!
PS:Web.Config和bin文件夹下的改动依然会让Web重启,这也是必须保留的!
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“asp.net 删除项目文件/文件夹IIS重启,Session丢失问题”评论...