【问题标题】:HttpRequest object in HealthMonitoringHealthMonitoring 中的 HttpRequest 对象
【发布时间】:2009-06-26 12:03:13
【问题描述】:

我正在为一个 asp .net 2.0 应用程序设置一些健康监控。

我希望能够获取原始网络请求对象。我希望能够检查通过发送的标头以及任何发布数据(如果可能)。

我目前有一个从 WebEventProvider 继承的事件提供程序,但这仅包括 HttpWebResponse 数据,不包括请求。

我该怎么办?

【问题讨论】:

    标签: asp.net health-monitoring


    【解决方案1】:

    您打算仅对您的应用程序或 IIS 中的所有应用程序进行健康监控吗?

    仅对于您自己的应用程序,您可以创建一个类并从 IHttpModule 派生,并在其 Init 方法中创建事件通知,甚至可以监控请求和任何其他状态。

    public class MyMonitor : IHttpModule
    {
    
            public void Init(HttpApplication context)
            {
                // you can watch any of such events and respond accordingly
                context.BeginRequest += new EventHandler(context_BeginRequest);
                context.PostUpdateRequestCache += 
                   new EventHandler(context_PostUpdateRequestCache);
                context.Error += new EventHandler(context_Error);
            }
            .....
    }
    

    您可以在 web.config 中添加以下行

    <httpModules>
        <add name="MyMonitor" type="Namespace.MyMonitor"/>
    </httpModules>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多