localhost + .Net with Fiddler

It is fairly common for a .Net web application to use ASP.Net as the UI tier and WCF services in the middle tier. After an application has grown in complexity, it can be difficult to see how and what WCF calls are being made.

Fiddler is an excellent tool for proxying HTTP requests for viewing HTTP traffic in transit, but it does not work with .Net applications when using localhost. To use fiddler in a 2-tiered environment with ASP.Net MVC as the UI tier and WCF service as the service tier, make the following changes:

1. Modify Service web.config

<system.net>
<defaultProxy>
<proxy
usesystemdefault="True"
bypassonlocal="False"
proxyaddress="http://127.0.0.1:8888"/>
</defaultProxy>
</system.net>

2. Modify UI web.config

<system.net>
<defaultProxy>
<proxy
usesystemdefault=”True”
bypassonlocal=”False”
proxyaddress=”http://127.0.0.1:8888″/&gt;
</defaultProxy>
</system.net>

<client>
<endpoint address=”http://ipv4.fiddler:56640/Service.svc&#8221; binding=”basicHttpBinding”
bindingConfiguration=”BasicHttpBinding_IService” contract=”ServiceReference1.IService”
name=”BasicHttpBinding_IService” />
</client>

That’s all! Enjoy!

Full code can be found on github: https://github.com/marksl/ASP.net-MVC-and-WCF-Sample

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to localhost + .Net with Fiddler

  1. David says:

    Hi,
    I downloaded your code and tried it in my local machine but it seems doesn’t work. Fiddler can capture request from localhost:56582, which is from browser to UI ASP.NET project, but not request from ASP.NET project to service project (at localhost:56580), do you mind telling me what’s the issue if it’s still working on your computer?
    Thank you very much

  2. David says:

    Oh sorry, please ignore my previous comment, it does working. The problem is I have a filter with url = localhost on, so it cannot capture request from ASP.NET project o Service project (which is actually at 127.0.0.1:56640 instead of localhost:56640). Turning off filter solves the issue

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s