0

Web 要求をログに記録する IHttpModule を作成しました。POSTリクエストを問題なく記録します。ただし、GET 要求の場合、長さは常にゼロのようです。GET リクエストの長さを取得する方法はありますか?

    public void Init(HttpApplication context)
    {
        context.BeginRequest += ContextBeginRequest;
    }

    private void ContextBeginRequest(object sender, EventArgs e)
    {
            string url = app.Request.RequestContext.HttpContext.Request.Url.ToString();
            string requestType = app.Request.RequestContext.HttpContext.Request.RequestType;
            long requestLength = app.Request.InputStream.Length;
            Log(url, requestType, requestLength);
    }
4

1 に答える 1

2

GET通常、リクエストにはメッセージ本文がないため、 はContent-Lengthゼロになります。

于 2014-06-23T06:18:31.583 に答える