Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I trace the HttpClient request using fiddler or any other tool?

I am using HttpClient for sending out request to one of the web api service that I don't have access to and I need to trace the actual request stream getting to the server from my client. Is there a way I can hookup the Fiddler to listen to the requests?

I am using the System.Net.Http.HttpClient class for sending out request.

Update: trying to improve this question now as I could not get what I was looking for. I am using a .Net Client application to connect to a Web Service hosted on my own IIS over HTTP channel. I have done the fiddler debugging earlier with a Website hosted on my IIS and watching the traffic generated between my browser and the WebSite. But when it comes to watching the traffic generated by a .Net client program talking to the web service using HttpClient class, strangely the fiddler does not seem to be able to tap that traffic and does not show anything. Is .Net HttpClient bypassing the WinInet API to connect to the service which results in the fiddler not able to watch the traffic?

like image 341
dhruvin Avatar asked Mar 19 '14 08:03

dhruvin


2 Answers

If you are connecting with a url like http://localhost:1234 change it to http://localhost.fiddler:1234/ and the requests from HttpClient should then become visible in Fiddler.

like image 189
Samuel Jack Avatar answered Oct 11 '22 01:10

Samuel Jack


Generally speaking, simply starting Fiddler before your application is sufficient. You haven't explained what you've tried so far.

  • If it doesn't just work, read: http://fiddlerbook.com/fiddler/help/hookup.asp#Q-DOTNET
  • If your target URL is localhost or 127.0.0.1, read: http://fiddlerbook.com/fiddler/help/hookup.asp#Q-LocalTraffic
  • If your code is running in IIS or ASP.NET, read: http://fiddlerbook.com/fiddler/help/hookup.asp#Q-IIS
like image 42
EricLaw Avatar answered Oct 11 '22 01:10

EricLaw