Debugging tools and tips for ASP.NET applications
When I develop ASP.NET applications or test my controls I make use of some tools which I thought would be useful listing, along with some tips.
- PocketSOAP TcpTrace and ProxyTrace are very simple tools which let you see the traffic flowing between you and a server (a local server too) in a raw fashion. They're almost identical in that they show what's passing through them, but when ProxyTrace acts as a proxy server (you choose a port to listen on and configure your browser to point to it), TcpTrace lets you choose both the port to listen on and the destination server:port pair; then it will redirect all the traffic coming from localhost:SourcePort to DestinationServer:DestinationPort.
I mostly use TcpTrace because it's faster to set up since you don't have to change the browser settings to make use of a proxy server. Suppose you are developing a web application with ASP.NET and want to see what's flowing between your browser and the ASP.NET Developement Server which comes with Visual Web Developer (asynchronous traffic too). As you know the VWD server starts on a dinamically chosen port, in order not to collide with other instances eventually running already. So you hold CTRL + F5 to start the all the stuff and you'll see that the browser points to http://localhost:SomePort/VirtualDirectory/PageName.aspx , where SomePort is the port it is listening on (in my case, at the moment, 3862). Now, in order to analyze the traffic, start TcpTrace and you are prompted to insert at least three parameters that you can set as follows:
- Listen on Port #: set it to an arbitrary number, this is the port you will point to with your browser. For example, 8080, but anything goes.
- Destination Server: set it to localhost.
- Destination Port #: set it to the value SomePort we saw before. It is the port the VWD server is listening on, in my example, 3862.
Click OK and you'll have TcpTrace listening on port 8080 and redirecting to port 3862 (and vice-versa). All that's left to do is set your browser to point to the new port, so you'll change only the port of the url from SomePort (3862) to 8080. Hit Enter and you'll be able to see all the Request/Response pairs in the TcpTrace GUI.
These are very simple tools, and will let you see only the raw data, but they are as simple as useful.
- Fiddler is a more advanced tool for debugging HTTP traffic. It acts in the same way as ProxyTrace does, except that when started it automatically configures Internet Explorer to make the traffic flow through the port it listens to (by default, 8888). In case you want to use it with another browser then you'll have to set its proxy settings to point to that port. Fiddler even installs itself as an IE plugin, so that you can start it directly from there.
Fiddler has many more features than the PocketSOAP suite, and the one I use most is its ability to show much more data about the Request/Response pair. In fact, it can show Request data as Headers, Text, Forms, Hex, Raw and Xml, and Response data as Headers, Text, Image, Hex, Caching, Privacy, Raw, Xml. It can even edit the response data, for example applying compression.
Another nice feature is the SyntaxView format, which is achieved installing a plugin which is available on its website and which shows Response data in the same fashion as you see it in the VWD editor. Very cool.
If you need advanced features Fiddler is absolutely the choice.
- Internet Explorer Developer Toolbar and Firefox Web Developer Toolbar are two toolbars with so many features that would take a book to describe them all. They are a must have for web developers. Among hundreds features, validation of markup, CSS, accesibility and so on as well as partial page source view (remember Ajax?). Just check them out and you'll see how useful they are.
- TamperIE and Tamped Data are two addins respectively for Internet Explorer and Firefox which allows editing the data submitted to the server either by GET or POST request. While GET requests can be easilly edited by hand since the name/value pairs are appended to the url, POST requests require such tools to be edited. Ok, maybe you thought you didn't need to validate POST data on the server because there was no way of tampering with it?...
- ieHTTPHeaders is an Explorer Bar for Microsoft Internet Explorer that will display the HTTP Headers sent and received by Internet Explorer as you surf the web. It can be useful in debugging various web-development problems related to cookies, caching, etc.
- Web Developement Helper by Nikhil Kotari is an Internet Explorer plugin that provides a set of useful tools to