Wednesday, October 13, 2010

Fiddler 2, WCF and .NET

If you are developing WCF web services using ASP.NET Development Server (runs asp.net app's locally) and you are using localhost, Fiddler will not be able to monitor any request/response traffic. Fiddler is bypassed if localhost is used.

Fiddler and Firefox

In Windows XP using .NET 3.5 VS2008 running a WCF REST web service (created in an ASP.NET Web App Project) you only need to replace localhost with your local machine name (a.k.a computer name), and Fiddler will monitor any requests to this service and the resulting response. Machine name can be found by right clicking 'My Computer' then selecting properties. Replacing localhost with your machine name only needs to be done on the client side (Firefox browser in this case). With an address like this

http://localhost:1355/MyService.svc/

replace localhost with your local machine name

http://machinename:1355/MyService.svc/

Fiddler will now display request/response information.

Fiddler and Internet Explorer

In Windows 7 running the same service mentioned above Fiddler can be used to monitor traffic by adding '.' (a full stop) to the end of localhost in your IE url, for eg

http://localhost.:1355/MyService.svc/

Fiddler will not be bypassed and requests made using IE will be picked up together with any resulting responses.

Just Fiddler

In addition to using Firefox or IE as a webclient you can also use Fiddler, click the RequestBuilder tab to enter urls.  Enter a url in the textbox beneath the request builder tab.

The url you enter will appear in the left window.


Once you click on the matching url in the left window, it will be highlighted blue. Select the Inspectors tab from the menu of the top right window. The top right window displays request information, the bottom right window displays responses sent back by the service. Select the Textview tab from the menu in the bottom right window, the web service response will be displayed.



 To make a post method request to a REST web service using Fiddler, enter the url then select Post method from drop down list.




In the Request Body window enter the values of your complex type object.