Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Boost ASP.NET Performance with Precompilation

Use ASP.NET Whidbey's precompilation feature to minimize the initial load time of your ASP.NET web pages, and avoid having to deploy your source code to the server.

he latest version of ASP.NET, version 2.0, supports several new and exciting features that promise to enhance developer productivity, administration and management, extensibility, and performance. One of these features is precompilation, which either developers or administrators can use to precompile ASP.NET applications before they are deployed. Moreover, the new precompilation feature can detect and provide warnings about any compilation failure issues, and lets you deploy applications without the need to store the source code on the deployment server. Precompilation can both reduce application response time and improve performance. This article explains how to use the new feature effectively.

Why Precompilation?
Dynamic compilation model of ASP.NET Whidbey refers to the ability of ASP.NET to compile the application's code dynamically at runtime. Because the ASP.NET framework senses changes to source pages, this capability means you can change your web page, and then reload it using the same request from a browser to see the page changes without having to recompile your entire web site. That's a great feature during development, but not necessarily after deployment, where you're less likely to be changing pages constantly. Using the default model, though, ASP.NET still compiles pages the first time they get requested, even on the deployment server, and even if the pages haven't changed since the last time that application was loaded. But what if you could precompile your entire web site before deployment? This is where ASP.NET 2.0's precompilation feature fits in.

Figure 1. Aspnet_compiler Syntax: You can see a list of aspnet_compiler.exe options by adding the "/?" option to the command line.
Precompilation in ASP.NET Whidbey is available in two modes.

  • In-place precompilation
  • Precompilation for deployment
In Place Precompilation
This option enables you to precompile your entire project. In essence, it compiles each and every page of your application and displays any compilation errors that occur. The tool you use to precompile applications is called aspnet_compiler and it resides in the %WINDIR%\Microsoft.NET\Framework\v2.x.xxxx directory. Figure 1 displays help on all the available options of this tool when invoked with the "/?" parameter from the command line.

While Figure 1 lists many options, the basic syntax for using this tool is as follows.

aspnet_compiler -v / -p

For example, you would use the following statement at the command line to precompile a "TestWebSite" virtual directory using the aspnet_compiler precompilation tool.

aspnet_compiler -v /TestWebSite

Figure 2. Temporary ASP.NET Files: By default, precompiled libraries get stored in the "Temporary ASP.NET Files" folder.
Note that the "-v" option shown above specifies a virtual directory. By default, the precompiled library created above gets stored in the Temporary ASP.NET Files directory as shown in Figure 2.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.