【问题标题】:IIS Application pool crashes when i create temp files in my virtual directory当我在虚拟目录中创建临时文件时,IIS 应用程序池崩溃
【发布时间】:2010-08-25 18:48:08
【问题描述】:

我有静态内容,如 html、css javascript 存储在 DB 中。当用户请求这些时,我在虚拟目录中创建一个临时文件并返回 url。

我的 Web 应用程序托管在 IIS 服务器上。在某些创建文件的系统上,我的 IIS 应用程序池崩溃并重新启动。如果我禁用文件监控虽然问题已经解决,但是当我在客户端部署时我没有这种奢侈。

有什么方法可以在文件创建期间避免应用程序池崩溃?

如果没有,有什么方法可以在不创建临时文件的情况下提供静态内容,如 html、css、图像、xml 和 js。我需要一种通用的方式来处理所有这些数据类型。

【问题讨论】:

    标签: asp.net iis


    【解决方案1】:

    在应用程序启动事件中执行的代码 sn-p 在根 web 文件夹上禁用文件更改通知

    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); //Returns NULL
    
    System.Reflection.MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); m.Invoke(monitor, new object[] { });
    

    还有另一个略有变化的sn-p

    var theRuntime = typeof(HttpRuntime).GetField("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
    var fcmField = typeof(HttpRuntime).GetField("_fcm", BindingFlags.NonPublic | BindingFlags.Instance);
    
    var fcm = fcmField.GetValue(theRuntime);
    fcmField.FieldType.GetMethod("Stop", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(fcm, null);
    

    在这两种情况下,脚本都需要管理员权限才能成功运行(尝试使用访客帐户但失败)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-25
      • 1970-01-01
      • 1970-01-01
      • 2010-10-08
      • 2010-10-03
      • 2013-11-16
      • 1970-01-01
      • 2018-04-25
      相关资源
      最近更新 更多