NetMF HTTP Debugging with Fiddler

Debugging problems with HTTP based connectivity on NetMF clients can be a bit awkward, particularly if the server side application is Azure based. You can debug an Azure application locally and call if from a NetMF device attached to you local network with a couple of hacks….

First configure fiddler to accept connections from remote clients and note down the port number

Fiddler Options

Connections Tab

On the device change the request URL to be a machine local one (cut n paste from the browser) for debugging using the Azure emulator or cloud one

private const string CloudServerUrl = @"http://127.0.0.1:81/positionUpdate.aspx";
or
private const string CloudServerUrl = @"http://myapplication.cloudapp.net/PositionUpdate.aspx";

Then setup the NetMF HTTP request proxy endpoint to be Fiddler

request.Headers.Add("x-DeviceMacAddress", DeviceMacAddress());
request.Headers.Add("x-3DFix", Gps.Fix3D.ToString());
request.Headers.Add("x-GPSTime", Gps.GPSTime.ToString("yyyy MM dd hh:mm:ss"));
request.Headers.Add("x-Latitude", Gps.Latitude.ToString("F6"));
request.Headers.Add("x-Longitude", Gps.Longitude.ToString("F6"));
request.Headers.Add("x-HDoP", Gps.hDop.ToString("F2"));
request.Headers.Add("x-Altitude", Gps.Altitude.ToString("F1"));
request.ContentLength = 0;

request.Proxy = new WebProxy("10.0.0.56", 8888 );

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
Debug.Print(" HTTP Status:" + response.StatusDescription);
if (response.StatusCode != HttpStatusCode.OK)
{
....
}
}

Then you should be able to see the requests & responses in Fiddler

POST http://127.0.0.1:81/positionUpdate.aspx HTTP/1.1
x-DeviceMacAddress: 5C-86-4A-00-3E-6B
x-3DFix: True
x-GPSTime: 2013 01 09 08:31:32
x-Latitude: -43.XXXX
x-Longitude: 172.XXXX
x-HDoP: 1.21
x-Altitude: 1.6
Content-Length: 0
Connection: Keep-Alive
Host: 127.0.0.1:81

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 09 Jan 2013 08:31:32 GMT
Content-Length: 17