加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-15 20:32:12 所属栏目:asp.Net 来源:网络整理
导读:在Global中 Application_Start 添加 如: 复制代码 代码如下: void Application_Start(object sender,EventArgs e) { //在应用程序启动时运行的代码 System.Reflection.PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor",S

在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[] { });
    }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读