Increase Web Site Scalability Using CompilationMode

Did you know that ASP.NET Web Sites allow developers to configure whether a page compiles or not.  Consider the following page directive:

<%@ Page Language="C#" CompilationMode="Never" %>

Setting the CompilationMode attribute to Never will disallow code on the page.  It will also prevent compilation to an assembly.  These pages can contain server controls or Expressions such as $AppSettings and $ConnectionStrings.

The main benefit is scalability.  In large web sites, this can avoid the need to compile high number of pages into assemblies.  Instead of compiling, these "no-compile" pages are processed by it's corresponding control builder which is preserved in memory for the life of the application.

You can also let ASP.NET determine if a page qualifies for "no-compile" automatically by making the following setting in web.config:


Skip to main content