无法通过HttpModule记录MDX查询

时间:2019-08-23 09:24:21

标签: c# asp.net iis

我正在使用IIS Server 6.2上托管的MDMD Pump,要求从Excel Pivot或任何其他来源命中时记录每个MDX查询。

解决了这个问题,我尝试将HttpModule作为类库,并部署在MSMD Pump部署所在的相同位置,并在web.config文件中添加了所需的配置。

以下我用于HttpModule的代码:

public class LoggerModule : IHttpModule
{
    public void Init(HttpApplication context)
    {
        context.PreSendRequestContent += new EventHandler(ContextPreSendRequestContent);
        context.BeginRequest += new EventHandler(ContextBeginRequest);
    }

    public void ContextPreSendRequestContent(Object sender, EventArgs e)
    {
        HttpRequest request = ((HttpApplication)sender).Request;
        HttpContext context = ((HttpApplication)sender).Context;

        if (request.InputStream.Length > 0)
        {
            var bytes = new byte[request.InputStream.Length];
            request.InputStream.Position = 0;
            request.InputStream.Read(bytes, 0, bytes.Length);
            string content = Encoding.ASCII.GetString(bytes);

            Logging(content);
        }
    }

    public void ContextBeginRequest(object sender, EventArgs e)
    {
        if (sender != null && sender is HttpApplication)
        {
            var request = (sender as HttpApplication).Request;
            var response = (sender as HttpApplication).Response;

            if (request != null && response != null && request.HttpMethod.ToUpper() == "POST")
            {
                var bytes = new byte[request.InputStream.Length];
                request.InputStream.Position = 0;
                request.InputStream.Read(bytes, 0, bytes.Length);
                string content = Encoding.ASCII.GetString(bytes);

                Logging(content);
            }
        }
    }

    public void Dispose()
    {

    }
}

BeginRequest事件-

在此事件中,获取每个请求的属性,例如RequestType,ContentType,Request Headers,但是当我尝试获取Request.InputStream的值时,则在excel中显示带有以下文本的异常提示。

  

“ XML分析在第1行第9列失败:禁止DTD”
  这表示500-服务器内部错误。

记录SOAP xml是:

  

<发现   xmlns =“ urn:schemas-microsoft-com:xml-analysis”> DISCOVER_PROPERTIES DbpropMsmdSubqueries < PropertyList />

PreSendRequestContent-

在某些解决方案中,我发现我们也可以使用此事件获取数据,但我的Request.InputStream长度为0。

0 个答案:

没有答案
相关问题