2014-06-23 2 views
0

웹 요청을 기록하는 IHttpModule을 만들었습니다. POST 요청을 잘 기록합니다. 그러나 GET 요청의 경우 길이는 항상 0 인 것처럼 보입니다. GET 요청의 길이를 얻을 수있는 방법이 있습니까?IHttpModule을 사용하여 로깅 요청 길이

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); 
    } 

답변

2

GET 요청은 일반적 따라서, Content-Length는 0이됩니다, 메시지 본문을 가지고하지 않습니다.

+0

감사합니다. Rodrick,하지만 전체 요청 길이는 어떻게 받습니까? (모든 HTTP 헤더 항목) – Fidel

+0

@Fidel 지금 테스트 할 수는 없지만 직접 서버 변수를 반복 해 볼 수는 있습니다. 나는 ALL_RAW로 시작하겠다. –

+0

감사합니다. Rodrick, 네 ServerVariables [ "ALL_RAW"]는 아주 가까이에 있습니다. 그러나 HTTP 요청의 첫 번째 줄을 포함하지 않습니다. – Fidel

관련 문제