Profiling ASP.NET 2.0 Web Applications with Red Gate’s ANTS Profiler and Microsoft’s Cassini Webserver

Recently I was in the need to speed up an ASP.NET 2.0 application.
Since I already own Red Gate’s ANTS Profiler and successfully managed to profile .NET 2.0 Windows Forms applications, I decided to use it for profiling my web application, too.

ANTS Profiler supports profiling web applications by attaching to a Microsoft Internet Information Services (IIS) webserver. Since I’m only using the Cassini webserver that ships with Visual Studio .NET 2005, I didn’t want to install a full blown IIS on my Windows XP development machine.
To get a solution, whether it is possible to profile web applications with Cassini, too, I started up the ANTS Profiler online manual, but found no related help. Next, I went straight to the online forum and found one thread discussing profiling an ASP.NET application indirectly by profiling the webserver as a Desktop application.

Following, I try to describe the steps how I succeeded.
First, you need to determine the command line to pass to ANTS Profiler. ANTS Profiler needs to be passed an executable (which is the path to the webserver executable) and the command line arguments.
The easiest way I found to determine all that information is to start the website from within Visual Studio .NET 2005 (e.g. by pressing “F5″). Next, start Process Explorer and inspect the properties of the “WebDev.Webserver.exe” process.


Copy/remember the settings displayed in this dialog box. Then, start up ANTS Profiler and select to profile a Desktop application and fill the values from Process Explorer.

Complete the wizard and be sure to stop the currently running webserver process before actually starting the profiler. This is required to free the port that the current running webserver occupies, since only one port can be used by one application at the same time.
After you closed/ended the running process, you can start profiling.
Fire up a web browser and simply let your application run as you previously did from within Visual Studio (be sure that you also have remembered the URL when initially starting the webserver from within Visual Studio when pressing “F5″, as described above).
Basically, that’s it!
Now you can normally click hyperlinks, visit pages, etc. Take snapshots as required to see the current profiler results.