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


Boost ASP.NET Performance with Precompilation : Page 2

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.

Precompilation for Deployment
This feature allows you to compile your project prior to its deployment. You can use this option to compile your projects into dynamically linked libraries and copy those to the deployment server. You no longer need to store your application's source code there.

Figure 3. Precompilation for Deployment: Using a command line like the one shown, you can precompile your project into DLL files for deployment on the server.
With this option, you have to specify the path to your source code and the path to the target directory where you need the compiled library to be stored. Figure 3 illustrates how to precompile a web site called "TestWebSite" using this tool and store the compiled library in the specified directory.

The statement shown in Figure 3 precompiles the specified web site and stores the compiled library in the "C:\TestWebSiteDeployment" directory. The "-p" option precedes the name of the source web site.

You can use the "-f" option of this tool to overwrite the content of the target directory if it already contains a compiled library with the same name (see Figure 4)

You can also precompile your web site using the "Publish Web Site" option of VS.NET 2005 as shown in Figure 5.

Figure 4. Overwriting Existing Files: Use the "-f' option to overwrite existing library files.
Figure 5. Precompiling in Visual Studio: You don't have to use the command-line tool; the Publish Web Site dialog lets you precompile a web site.
If you check the option "Allow this precompiled site to be updatable" in the Publish Web Site dialog as shown in Figure 5, you'll find that the initial load time for web pages in the site will still be expensive. That's because when you specify that option, the ASP.NET runtime environment still has to compile the web page dynamically the first time it is requested. Therefore, unless you need to update your web pages frequently, precompile your web site with the option unchecked to minimize the initial load time.

Apart from using the precompilation feature, my previous article on ASP.NET performance shows other ways to reduce the load time of your .aspx web pages the first time they are requested.

Joydip Kanjilal has over 10 years of industry experience with C, C++, Java, C#, VB, VC++, ASP.Net, XML, Design Patterns, UML, etc. He currently works as a senior project leader in a reputable multinational company in Hyderabad, India, and has contributed articles on .NET and related technologies to www.aspalliance.com.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date