Your strategic advantage starts here

Debug SOAP and REST in IIS Express using Fiddler

Debug SOAP and REST in IIS Express using Fiddler

I’ve been using Visual Studio 2013 Express to make a C# website that uses SOAP to request services from another company.  Everything was working fine, until one day I suddenly started getting HTTP 500 errors.  Naturally the service provider said it wasn’t them, so out came Fiddler.  Funnily enough the request worked straight away in Fiddler, so I needed to find out what the difference was between a Fiddler request and a request from my localhost.

I followed this guide here: http://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/ConfigureDotNETApp

However:

GlobalProxySelection.Select = new WebProxy(“127.0.0.1”, 8888);

should now be:

WebRequest.DefaultWebProxy = new WebProxy(“127.0.0.1”, 8888);

Because of this issue, we can’t debug simply using ‘localhost’.  So I used this guide to use a custom host name as opposed to ‘localhost’ – using the following locations as reference for the applicationhost.config file:

Pre-Visual Studio 2015

%userprofile%\documents\iisexpress\config\applicationhost.config
%userprofile%\my documents\iisexpress\config\applicationhost.config

Visual Studio 2015+

$(solutionDir)\.vs\config\applicationhost.config

In Fiddler, because I’m using HTTPS, I had to go to Tools > Fiddler Options > HTTPS tab and check ‘Decrypt HTTPS traffic’

And finally I needed to add this line BEFORE my C# HttpWebRequest code for the request to work properly when Fiddler was running:

ServicePointManager.ServerCertificateValidationCallback +=(sender, cert, chain, sslPolicyErrors) => true;

I think that’s it…..

Related Posts
Leave a Reply
Give us a call

Available from 9am to 8pm, Monday to Friday.

Send us a message

Send your message any time you want.

Our usual reply time: 1 Business day
Give us a call

Available from 9am to 8pm, Monday to Friday.

Send us a message

Send your message any time you want.

Our usual reply time: 1 Business day