Dynamic Compilation of ASP.NET Pages

When we creates a page in ASP.NET internally it create a .NET class. i.e: An instance of System.Web.UI.Page class. All the content in ASP.NET page including scripts,HTML content and plain text is compiled into .NET class.

When a client request for ASP.NET page then ASP.NET Framework searches for a .NET class corresponding to the page then executes the class.If the class is not found then it compiles the page into new .NET class and stores the class into temporary ASP.NET folder in the following location.

in .NET Framework 4.0 beta 2
"\Windows\Microsoft.NET\Framework\v4.0.21006\Temporary ASP.NET Files"

up to .NET Framework 3.5
"\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files"

If anyone request for same page next time again page is not complied. The corresponding class will be executed. Until unless the page is not compiled again the source code is modified.This process is called "Dynamic Compilation".

When the page is compiled into class then there is a dependency is created between the ASP.NET page & .NET class. If the source code of the page is modified corresponding .NET class will be deleted.If user next time request the page then it will compiled into new .NET class. Unlike classical ASP application the pages are not compiled every time when the user requests.

We have option to precompile an entire ASP.NET application using aspnet_compiler.exe command line tool.If we precompile an application ,user doesn't experience the compilation delay for first page request.

How to disable dynamic compilation ?

We have attribute "CompilationMode" if we use this with <%@Page%> directive we can disable the dynamic compilation for a page. If we use this in tag in web.config we can disable for pages in a folder or even for complete application.

This article is part of the GWB Archives. Original Author: Shravan Kumar

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.