Profiling ASP.NET Applications via the ASP.NET

ASP.NET applications can be considered as Internet Information Services (IIS) applications that are built with .NET compilers and use functionality provided by the .NET Framework and .NET assemblies. The manner that you profile your ASP.NET application depends on the development tool that you used to create it.

Any ASP.NET application created in any development tool can be profiled using IIS. The technique of profiling ASP.NET applications with IIS is described in AQtime’s on-line help (see the “Profiling ASP.NET Applications” topic).

However, if you have created your ASP.NET application or service in Microsoft Visual Studio 2005, you can use the dedicated ASP.NET Development Server for profiling. This server is integrated into Microsoft Visual Studio 2005 and is generally used in place of IIS to develop and debug ASP.NET applications. It can also be used for profiling ASP.NET applications in AQtime.

The only issue with the ASP.NET Development Server is that AQtime can only use it when profiling 32-bit ASP.NET applications, because the server can only run in 32-bit mode. Even though you can rebuild your application for a 32-bit platform and use the ASP.NET Development Server, profiling an application in 32-bit mode under a 64-bit platform produces inaccurate results. So, if the ASP.NET application is designed for the 64-bit platform, it is better to profile it using IIS.

Now I am going to explain how to configure an AQtime project for profiling ASP.NET applications using the ASP.NET Development Server.

The explanations below assume that ASP.NET is running in the default configuration. If ASP.NET is running under a user account, you should specify certain permissions for this account (see the “Profiling ASP.NET and IIS Applications: ASP.NET or IIS is Running Under a User Account” topic in AQtime’s on-line help for details).

Before profiling your ASP.NET application, you need to build or publish it:

  1. Open your application project in Visual Studio.
  2. Build or publish your application. To build the application, select Build | Build Web Site from Visual Studio’s menu. To publish the application, select the Build | Publish WebSite item in Visual Studio’s menu and uncheck the “Allow this precompiled site to be updatable” check box in the ensuing Publish Web Site dialog.

    I recommend that you publish your application. When you build the application, Visual Studio organizes the application code into several temporary DLLs whose names and locations are defined by Visual Studio and are changed from one compilation to another. You will have to add application modules to the AQtime project every time you recompile your application. Since modules’ names and paths are defined by Visual Studio, you cannot be sure that you have found and added all needed modules. When you publish the application, all of its DLLs are placed in the same folder, so it is a lot easier to locate and manage them.

To configure the AQtime project:

  1. Run Aqtime and create a new project, using the File | New Project menu item.
  2. Add the application’s library modules to the project. To add a module, use the Project | Add Module menu item.

    If you have published your application, add all the application modules that are in the folder where you published your application.

    If you did not publish the application, you can still profile all application modules by adding any application module and check the Profile Entire .NET Code option in the Areas pane.

  3. In the Profiling Mode dropdown list on AQtime’s Standard toolbar, select Normal.
  4. Select Run | Parameters from AQtime’s main menu. In the ensuing Run Parameters dialog, you need to specify the path to the ASP.NET Development Server executable (the Host Application field) and command-line parameters for the server (the Parameters field).

    The path to the ASP.NET Development Server file is as follows:

    <Windows>Microsoft.NETFramework<Framework_Version>WebDev.WebServer.exe

    <Windows> is the Windows folder path (for example, C:Windows) and <Framework_Version> is the version of the .NET Framework installed (for example, v2.0.50727). You can press the ellipsis button on the right of the Host Application field and easily locate the ASP.NET Development Server executable in the standard Open File dialog. The command-line parameters include the port number, the physical path of the profiled ASP.NET application and, optionally, the virtual path to the application. The command line has the following syntax:

    /port:<port_number> /path:<physical_path&Gt; [/vpath:<virtual_path>]

    • <port_number> – The number of the unused port, between 1 and 65535,
    • <physical_path> – The name of the directory where your ASP.NET application is located (for example, “C:WorkMyApp”),
    • <virtual_path> – [Optional] A virtual path or application root in the form ‘/‘ (for example, “/MyApp”). The default value is ‘/’.

      The sample command line looks like:

      /port:1169 /path:”C:WorkMyApp” /vpath:”/MyApp”

    After you have specified the ASP.NET Development Server path and its command line, click OK to close the dialog and save the parameters.

  5. Select the desired profiler (Performance, Allocation or other) from the list of profilers on AQtime’s toolbar.
  6. Save the project by selecting File | Save Project from AQtime’s menu and specifying the name of the file where you will save the project.

      Now we are ready to profile the project:

      1. To start profiling, select Run | Run from AQtime’s menu or press the Run button on the toolbar. AQtime may ask your permission to restart the IIS Admin service. Answer “Yes” to this question.
      2. Launch Internet Explorer and open the application’s main page (for example, http://localhost/MyApp/main.aspx).
      3. Perform profiling as your needs dictate.

      To obtain profiling results, select Run | Get Results from AQtime’s menu.

      To terminate the profiler run, select Run | Terminate from AQtime’s main menu or press Terminate on the Standard toolbar.