Boost ASP.NET Performance with Precompilation

Boost ASP.NET Performance with Precompilation

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.NETFrameworkv2.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.

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.

devx-admin

devx-admin

Share the Post:
Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023,

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed

Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at the Lubiatowo-Kopalino site in Pomerania.

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will result in job losses. However,

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023, more than one-fifth of automobiles

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed are at the forefront because

Sunsets' Technique

Inside the Climate Battle: Make Sunsets’ Technique

On February 12, 2023, Luke Iseman and Andrew Song from the solar geoengineering firm Make Sunsets showcased their technique for injecting sulfur dioxide (SO₂) into the stratosphere as a means

AI Adherence Prediction

AI Algorithm Predicts Treatment Adherence

Swoop, a prominent consumer health data company, has unveiled a cutting-edge algorithm capable of predicting adherence to treatment in people with Multiple Sclerosis (MS) and other health conditions. Utilizing artificial

Personalized UX

Here’s Why You Need to Use JavaScript and Cookies

In today’s increasingly digital world, websites often rely on JavaScript and cookies to provide users with a more seamless and personalized browsing experience. These key components allow websites to display

Geoengineering Methods

Scientists Dimming the Sun: It’s a Good Thing

Scientists at the University of Bern have been exploring geoengineering methods that could potentially slow down the melting of the West Antarctic ice sheet by reducing sunlight exposure. Among these

why startups succeed

The Top Reasons Why Startups Succeed

Everyone hears the stories. Apple was started in a garage. Musk slept in a rented office space while he was creating PayPal with his brother. Facebook was coded by a

Bold Evolution

Intel’s Bold Comeback

Intel, a leading figure in the semiconductor industry, has underperformed in the stock market over the past five years, with shares dropping by 4% as opposed to the 176% return

Semiconductor market

Semiconductor Slump: Rebound on the Horizon

In recent years, the semiconductor sector has faced a slump due to decreasing PC and smartphone sales, especially in 2022 and 2023. Nonetheless, as 2024 approaches, the industry seems to

Elevated Content Deals

Elevate Your Content Creation with Amazing Deals

The latest Tech Deals cater to creators of different levels and budgets, featuring a variety of computer accessories and tools designed specifically for content creation. Enhance your technological setup with

Learn Web Security

An Easy Way to Learn Web Security

The Web Security Academy has recently introduced new educational courses designed to offer a comprehensible and straightforward journey through the intricate realm of web security. These carefully designed learning courses

Military Drones Revolution

Military Drones: New Mobile Command Centers

The Air Force Special Operations Command (AFSOC) is currently working on a pioneering project that aims to transform MQ-9 Reaper drones into mobile command centers to better manage smaller unmanned

Tech Partnership

US and Vietnam: The Next Tech Leaders?

The US and Vietnam have entered into a series of multi-billion-dollar business deals, marking a significant leap forward in their cooperation in vital sectors like artificial intelligence (AI), semiconductors, and

Huge Savings

Score Massive Savings on Portable Gaming

This week in tech bargains, a well-known firm has considerably reduced the price of its portable gaming device, cutting costs by as much as 20 percent, which matches the lowest

Cloudfare Protection

Unbreakable: Cloudflare One Data Protection Suite

Recently, Cloudflare introduced its One Data Protection Suite, an extensive collection of sophisticated security tools designed to protect data in various environments, including web, private, and SaaS applications. The suite

Drone Revolution

Cool Drone Tech Unveiled at London Event

At the DSEI defense event in London, Israeli defense firms exhibited cutting-edge drone technology featuring vertical-takeoff-and-landing (VTOL) abilities while launching two innovative systems that have already been acquired by clients.

2D Semiconductor Revolution

Disrupting Electronics with 2D Semiconductors

The rapid development in electronic devices has created an increasing demand for advanced semiconductors. While silicon has traditionally been the go-to material for such applications, it suffers from certain limitations.

Cisco Growth

Cisco Cuts Jobs To Optimize Growth

Tech giant Cisco Systems Inc. recently unveiled plans to reduce its workforce in two Californian cities, with the goal of optimizing the company’s cost structure. The company has decided to

FAA Authorization

FAA Approves Drone Deliveries

In a significant development for the US drone industry, drone delivery company Zipline has gained Federal Aviation Administration (FAA) authorization, permitting them to operate drones beyond the visual line of

Mortgage Rate Challenges

Prop-Tech Firms Face Mortgage Rate Challenges

The surge in mortgage rates and a subsequent decrease in home buying have presented challenges for prop-tech firms like Divvy Homes, a rent-to-own start-up company. With a previous valuation of

Lighthouse Updates

Microsoft 365 Lighthouse: Powerful Updates

Microsoft has introduced a new update to Microsoft 365 Lighthouse, which includes support for alerts and notifications. This update is designed to give Managed Service Providers (MSPs) increased control and

Website Lock

Mysterious Website Blockage Sparks Concern

Recently, visitors of a well-known resource website encountered a message blocking their access, resulting in disappointment and frustration among its users. While the reason for this limitation remains uncertain, specialists