Compilation in ASP applications
First, let's take a moment to revisit compilation in the context of the ASP. There is generally the types of compilation that typically take place in an ASP. Application:project, and Runtime Compilation.
Project compilation
This type of compilation was used by ASP. Applications built using the project system approach, i.e. they has a. CSP Roj/.vbproj file. Project compilation typically takes place in Visual Studio via the project system and MSBuild. It compiles any C # or VB files in your project and produces a assembly in the project ' s Bin folder. This assembly are then deployed to your Web server along with your application and are loaded by the ASP. UR application starts. Note This assembly could also is built from the command line using MSBuild directly, e.g. when on a continuous integration or build server.
Assets such as page, user control, and handler Code-behind classes, controllers and embedded resources are built using Pro Ject compilation. Typically the source code for these assets are not deployed to the server. Other asset types, including. aspx,. ascx,. ashx,. cshtml, and. Vbhtml, is deployed to the server and built by the ASP. NET runtime itself using Runtime compilation.
Runtime compilation
ASP. Includes a full runtime compilation pipeline This compiles many of your application ' s assets on the Web server whe n the application is running (hence "Runtime Compilation). Even if you ' re using the project compilation model detailed above, part of your application would be compiled using ASP. ' s runtime compilation feature. If you ' re using the "Web site" model for your application (you chose file–> New Web site ... in Visual Studio and your AP Plication doesn ' t has a. csproj/.vbproj file) Your application is built exclusively using ASP. NET ' s compilation system. In this model, your application would contain shared code files in the App_Code folder.
Page assets in your application such as. aspx,. ascx and. cshtml/.vbhtml files, is compiled in the following fashion:
- The file is parsed and turned into CodeDOM using the configured build provider
- The CodeDom graph that represents the file was used to generate a string of C # or VB code using the configured CodeDOM Prov Ider (the Code generation Step)
- The C # or VB code is then compiled to an assembly using the configured CodeDOM provider (the code compilation Step)
- The assembly is loaded into the application and optionally cached to disk in the temporary ASP. NET Files folder
You can read more about ASP. NET ' s compilation system on MSDN.
Runtime pre-compilation
To confuse matters slightly, you can elect to pre-compile the portions of the your application this use the ASP. NET Runtime Co Mpilation system before deployment, so-the compilation doesn ' ttake the place at runtime. This is achieved using the ASP. Compilation Tool, Aspnet_compiler.exe. This would produce assemblies that can is deployed along with your application in the Bin folder and would remove the cost a Ssociated with compiling those assets when the application starts up. The tool is simply a wrapper around the runtime compilation feature and doesn ' t with MSBuild in any. It would only be compile the portions of your application that would ' ve been compiled at runtime by ASP, so if you ' re usin G The project compilation model from above, you'll still need to compile your application ' s project using Visual Studio or Msbuild.
You can read more about the ASP. NET pre-compilation on MSDN.
ASP. NET ' s compilation system