Chapter 6. Performance

ASP.NET 2.0 includes new features that enhance the performance of your web applications. For example, in ASP.NET 1.x, pages are dynamically compiled and cached the first time a user loads a page. As a result, an ASP.NET 1.x web application is typically slower the first time it is loaded. In ASP.NET 2.0, you can now precompile your site so that it’s already compiled when the first user pays a visit.


You can now make changes to your ASP.NET 2.0 web application and it will recompile on the fly.

In ASP.NET 1.x, all code-behinds are compiled into an assembly and stored in the /bin directory of the application, while the web pages (.aspx) are compiled on demand. And so any changes made to the .aspx page will automatically be updated, whereas changes to the code-behind of the page will not be recompiled until you explicitly request it.

In ASP.NET 2.0, you can use dynamic runtime compilation so that any changes made to either the .aspx or .vb (or .cs) files will automatically trigger a recompilation of the page.

How do I do that?

To verify that ASP.NET 2.0 will dynamically recompile your .aspx and code-behind files, you will create a web application that uses a class stored in a special directory called App_Code. When the class stored in the App_Code folder is modified, ASP.NET 2.0 will automatically recompile it when the page is requested.

  1. Launch Visual Studio 2005 and create a new web site project. Name the project C:\ASPNET20\chap06-DynamicRecompilation.

  2. To use ...

Get ASP.NET 2.0: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.