ASP.NET 程序中删除文件夹导致session失效问题的解决办法分享

来源:互联网 发布:淘宝搜索黑科技 编辑:程序博客网 时间:2024/04/30 06:45
这篇文章主要介绍了ASP.NET 程序中删除文件夹导致session失效问题的解决办法分享,有需要的朋友可以参考一下

在Global中  Application_Start 添加

如:
 代码如下:

void Application_Start(object sender, EventArgs e)
    {
        //在应用程序启动时运行的代码
        System.Reflection.PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
        object o = p.GetValue(null, null);
        System.Reflection.FieldInfo f = o.GetType().GetField("_dirMonSubdirs", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.IgnoreCase);
        object monitor = f.GetValue(o);
        System.Reflection.MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        m.Invoke(monitor, new object[] { });
    }

0 0
原创粉丝点击