Friday, February 19, 2010

Using Fiddler with ASP.NET Web Development Server with Silverlight in IE

Whilst trying to debug an issue with Silveright RIA services I wanted to use Fiddler to see what was being returned by the server (as the client told me the service/method was not found - this is not the whole truth it turned out).


My first problem was that the ASP.NET Web Development Server (WDS) starts on a URL such as http://localhost:4567/default.aspx and when using IE on localhost Fiddler will not capture the traffic.

What you need to do is use a name other than localhost then Fiddler will capture for you. However, as WDS cannot be (from what I found) changed to start on anything but localhost Fiddler needs to know how to handle this.

What is needed is Rule in Fidder to handle this, a rule than will take the URL


http://mydomain:4567/default.aspx


and change it to


http://127.0.0.1:4567/default.aspx


This is pretty simple to setup. CTRL+R in Fidder will bring up the Fidder2 Script Editor in which you can edit your rules.
Find the function static function OnBeforeRequest(oSession: Session) and at the end of it add a rule like so:


oSession.host = oSession.host.replace("mydomain","127.0.0.1");


Save you updated rules script and exit.

Now, when you browse (/debug) your Silverlight app you should do so using http://mydomain:4567 rather than localhost and traffic will be captured.

One minor irritation that I also had to overcome was that when the SL project started (and immediately hit an error) it was doing so on http://localhost:4567/ and so I did not see the traffic.

To get around this problem I added a start page (actually just edited the default.aspx in the SL web project) so that it contains a hyperlink to the Silverlight test page using the required URL such as http://mydomain:4567/SLAppTestPage.aspx; this page now having traffic captured by Fiddler and allowing me to see the real reason behind my RIA Service call failures.

No comments:

Post a Comment