Understanding ASP. NET pre-compilation, understanding asp.net Compilation

Source: Internet
Author: User

Understanding ASP. NET pre-compilation, understanding asp.net Compilation

I. Advantages of pre-Compilation

1. Because pages and code files do not need to be compiled when they are requested for the first time, the response time to users can be shortened. This is particularly useful for large websites with frequent updates.

2. You can identify the Bug during compilation before you see the website.

3. You can create a compiled version of the site and deploy the version to the production server without using the source code.

2. Local pre-compilation and pre-compilation for deployment

1. Local pre-Compilation

In-Place pre-compilation websites can effectively execute the compilation process that occurs when a user requests a webpage. Therefore, the main performance improvement is that the page does not need to be compiled during the first request.

The compiled file is stored in % SystemRoot % \ Microsoft. NET \ Framework \ version \ Temporary ASP.. NET Files folder, and then ASP. NET will use the Assembly in this folder to complete the page request.

If the site is pre-compiled again, only new or changed files (or those files that are dependent on the new or changed files) will be compiled ).

2. Pre-compilation for deployment

For deployment pre-compilation, the compiler will generate an Assembly Based on almost all ASP. NET source files compiled at runtime under normal circumstances. The compiler will generate source code and markup from the output. The compiled file extension is. compiled.

To change the content of a website page, you must update the original file, recompile the website, and redeploy it. The only exception is the website configuration file web. config.

Iii. configuration items pre-compiled by Visual Studio

Iv. Analysis of advanced pre-compilation settings

1. Pre-compilation Options> allow update of pre-compilation sites (not checked), merge options> unmerged (checked) Scenarios

As you can see, the compiled file appears directly in the bin directory. If you try to open the view file in the Views folder, you will see "this is the mark file generated by the Pre-compilation tool, should not be deleted!" The prompt information also indicates that this pre-compilation scheme will cause the source file to be re-precompiled and then released each time the View File is modified.

2. Pre-compilation Options> allow update of pre-compilation sites (not checked), merge options> not merged. Create a separate assembly (checked) for each page and Space

The difference with scenario 1 is that the dll file retains the information of the View File name, which is more straightforward.

3. Pre-compilation Options> allow update of pre-compilation sites (not checked), merge options> merge all output to a single assembly, named SingleAssmy (checked)

We can see that all the dll files are merged into SingleAssmy. dll. decompile the files to check the code,

This Assembly does contain all assembly information.

4. Pre-compilation Options> allow update of pre-compilation sites (not checked)

Merge option: Merge the output of each folder to its own assembly.

Merge option: merge all page and control output to a single assembly

There is no difference between the two configurations ......

V. Personal Summary

To use deployment pre-compilation, we recommend that you use solution 2 (pre-compilation Options> allow update of pre-compilation sites (not checked), merge options> not merge. create a separate Assembly for each page and space (select) scenario)

After the test, the page starts very fast after each release, and solution 2 can clearly see the pre-compiled dll file name to facilitate a single update.

Disadvantage: each view file must be pre-compiled and published for editing.

Use command lines to deploy pre-Compilation

cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319
aspnet_compiler -f -p "D:\Work\ASPNET\PreCompiled.Web\PreCompiled.Web" -v / "E:\Release\PreRelease" -fixednames
E:
cd /Release/PreRelease/bin
del *.xml
cd ..
rd /s/q App_Start
rd /s/q Controllers
rd /s/q Models
rd /s/q obj
rd /s/q Properties
del *.csproj
del *.user
del Web.Debug.config
del Web.Release.config
PAUSE

References:

Https://msdn.microsoft.com/zh-cn/library/bb398860 (v = vs.100). aspx

Https://msdn.microsoft.com/zh-cn/library/ms229863 (v = vs.100). aspx # findingthecorrectversion

Https://msdn.microsoft.com/zh-cn/library/ms228040 (v = vs.100). aspx

Http://stackoverflow.com/questions/19810145/web-config-error-unrecognized-attribute-xmlnsxdt-note-that-attribute-names

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.