When writing mobile web applications that work against a RESTful API its useful to be able to trace all HTTP traffic generated by the app. In this post, I’m going to describe how to set up an ASP.NET Web API project hosted within IIS Express so that you can view the traffic generated by a mobile device (i.e. your iPhone). The technique I’m outlining here does _not_ rely on configuring a proxy on the mobile device, which is cumbersome in case you don’t have a device reserved exclusively for development. Replace the ports and hostnames in the instructions below to fit your environment. This setup requires that you can resolve your dev machines’ hostname using DNS in your local network.
Expose IIS_Express on the FQDN of your host
C:\Users\YourUser\Documents\IISExpress\config\applicationHost.config and edit the binding for your web api project.
<binding protocol="http" bindingInformation="*:1182:localhost" /> with
<binding protocol="http" bindingInformation="*:1182:hostname.domain.com" />
Add a URL Reservation:
We need to allow external connections on the port used by IIS Express. Run the following command from an elevated prompt:
netsh http add urlacl url=http://hostname.domain.com:1182/ user=everyone
Configure Fiddler to proxy incoming traffic
See http://www.fiddler2.com/Fiddler/Help/ReverseProxy.asp and use option#2.