2009-04-13 5 views
4

내 dev 컴퓨터에서 IIS 5를 실행합니다. 나는 asp.net 3.5 웹 서비스를 실행하고있어 다른 웹 응용 프로그램에서 동일한 서버에서 실행 중입니다. 내 서비스에서 오류 500 내부 서버 오류를 반환하고 문제를 해결할 예정입니다. 내 요청은 System.Net.HttpWebRequest 개체를 통해 전송되며 클라이언트의 관점에서 유효하게 보입니다.IIS로 들어오는 HTTP 요청을 기록하는 방법

원시 수신 HTTP 요청을 서버 관점에서보고 싶습니다. 서비스가 루프백에서 호출되기 때문에 Wireshark를 사용하여이를 볼 수 없습니다.

IIS 로깅은 요청 헤더를 표시하지만 게시 내용은 표시하지 않습니다.

IIS에서 수신되는 전체 원시 HTTP 요청을 볼 수있는 방법에 대한 제안 사항은 무엇입니까? 내가 생각

감사

답변

3

당신은 로깅을위한 HttpModule을 추가하고 싶습니다. Here's ASP.NET 모듈 및 처리기에 대한 유용한 정보 :

그런 식으로 로깅을 사용하지 않으려면 web.config 파일에서 제거/주석 처리 만하면됩니다.

0

가장 좋은 방법은 다른 포트에서 각각의 웹 응용 프로그램을 실행 한 다음 Fiddler과 같은 것을 사용하여보고 싶은 포트의 프록시를 만드는 것입니다. 그러면 특정 응용 프로그램과의 모든 트래픽이 모니터링됩니다.

5

Fiddler을 사용해 보셨나요? 그냥 localhost 대신 컴퓨터 이름을 사용하십시오.

+1

피들러가 작동합니다. 내 응용 프로그램 내에서 웹 서비스 호출이 작동하지 않습니다. –

+2

@ Mr Greieves, 약간의 추가 작업이 필요하지만 웹 서비스 호출에 대한 프록시 설정을 수동으로 구성 할 수 있습니다. –

0

다음은 HTTP POST 요청 데이터를 기록하는 데 사용하는 사용자 정의 HTTP 모듈의 코드입니다.

using System; 
using System.Web; 

namespace MySolution.HttpModules 
{ 
    public class HttpPOSTLogger : IHttpModule 
    { 

     public void Dispose() 
     { 
     } 

     public void Init(HttpApplication context) 
     { 
      context.BeginRequest += new EventHandler(context_BeginRequest); 
     } 

     private void context_BeginRequest(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 body = HttpUtility.UrlDecode(request.Form.ToString()); 
        if (!string.IsNullOrWhiteSpace(body)) 
         response.AppendToLog(body); 
       } 
      } 
     } 

    } 
} 

응용 프로그램의 web.config에 등록하는 것을 잊지 마십시오. 적용 모듈 전에 IIS 클래식 모델

<system.web> 
    <httpModules> 
     <add name="HttpPOSTLogger" type="MySolution.HttpModules.HttpPOSTLogger, MySolution.HttpModules"/> 
    </httpModules> 
</system.web> 

IIS 로그의 IIS 통합 모델

<system.webServer> 
    <modules> 
     <add name="HttpPOSTLogger" type="MySolution.HttpModules.HttpPOSTLogger, MySolution.HttpModules" /> 
    </modules> 
</system.webServer> 

사용 system.web 섹션

사용의 system.webServer 섹션 :

::1, -, 10/31/2017, 10:53:20, W3SVC1, machine-name, ::1, 5, 681, 662, 200, 0, POST, /MySolution/MyService.svc/MyMethod, -, 

IIS 로그 적용 후 :

::1, -, 10/31/2017, 10:53:20, W3SVC1, machine-name, ::1, 5, 681, 662, 200, 0, POST, /MySolution/MyService.svc/MyMethod, {"model":{"Platform":"Mobile","EntityID":"420003"}}, 

전체 기사 : 당신이 브라우저에서 조회하는 경우

https://www.codeproject.com/Tips/1213108/HttpModule-for-logging-HTTP-POST-data-in-IIS-Log

관련 문제