Developers of ASP. NET 1.x often hear users' complaints about the first application call.ProgramInitialization latency. After all, the initial request will lead to a series of processes, including Runtime Library initialization, analysis, compiling the ASPX page into an intermediate language, and real-time compilation of methods.CodeAnd so on.
Developers of ASP. NET 1.x often hear users complain that initialization delays occur when applications are called for the first time. After all, the initial request will lead to a series of processes, including the initialization and Analysis of the Runtime Library, compiling the ASPX page into an intermediate language, and compiling the code of the method in real time.
Since ASP. NET became available, developers have been asking for a solution (Microsoft), while ASP. NET 2.0 provides an effective solution by using pre-compilation.
Pre-compilation options
When the application is started for the first time, ASP. NET dynamically analyzes and compiles all ASP. NET files (aspx pages ). The runtime environment should buffer the compiled results to better serve all future requests.
After the server or web server is restarted, the first time the application is started, the process needs to be restarted. In addition, any file changes to the application will be detected by the system, and the first time the application is run after the file changes, this process will happen again.
Many Web developers hate this initialization latency. Precompilation avoids this Latency by compiling the application in advance.
Command Line
You can start the pre-compilation by using the aspnet_compiler.exe program installed in the .netframework 2.0. It is located in the framework installation directory (the version number varies according to the installed Framework Version ). The following is the default path of the program:
The following is a code snippet:
C: \\\ Microsoft. NET http: // Www.cnblogs.com/simcoder/admin/file: // Framework // V2.0.5072 // Aspnet_compiler.exe
You can use -? This command parameter is used to view the list of all parameters of the program. Below I will explain some available parameters:
M: This parameter indicates that you will use the complete IIS metabase path that the application will be precompiled. The path of the IIS metabase is/lm/w3svc/1/root/Application name.
V: Use the virtual IIS path of the Web application to be precompiled. The format of the virtual path is/Application name.
P: Use the physical IIS path of the Web application to be precompiled. It includes the drive name and the full path to the application directory. For example, c: \ Inetpub \ wwwroot \ Application name. The V parameter must be used with P, so the compiler can parse the root reference of any application.
F: indicates whether the target directory is to be overwritten.
U: used to set the pre-compiled application to be updated. This means that all the tag files (aspx, ascx, and so on) can be updated in the target directory.
Targetdir: The target directory used to pre-compile the application file. The following command precompiled an application using the virtual path and the specified target path: aspnet_compiler.exe-V/Application name c: \ target directory name.
If no target directory is specified, the result file will be placed in the temporary file directory of ASP. NET, just like processing and compiling when ASP. NET Runtime Library calls the application for the first time. The default path of the temporary directory is as follows:
The following is a code snippet:
C: \ Windows \ Microsoft. NET \ framework \ V2. 0.50727 \ Temporary ASP. NET files \\
Application name
Another advantage of pre-compilation is the ability to capture any errors that occur during the application startup phase. Errors are displayed in the tool, but the compilation process is not terminated.
HideSource code
Another by-product of pre-compilation is the ability to hide any or all application source code. This means that other developers need to use The Decompilation program or ilasm to obtain your code. That's all. Pre-compilation allows you to distribute applications in the form of binary files.
There is no source code in the target directory. All classes in the app_code folder are compiled into one or more binary files and placed in the bin directory. The target directory does not contain source code files (. CS ,. VB ,. JS ). In addition, all home page files are compiled to the bin directory as hidden files. All codes and tags of aspx, ascx, and ashx files, and related code hidden files are stored in one or more collections in the bin directory.
Hidden source code is a mixed reputation. Other developers cannot view or change the application in any form-even web page markup. On the other hand, any changes to the application (regardless of the size) require changes to the original source code, re-compilation, and re-deployment. This may be a very time-consuming process, so it does not necessarily apply to all applications.
The updatable command parameter (u) allows you to replace this default behavior. Using this parameter means that all markup files (aspx, ascx, and so on) must be included in the output of the pre-compilation process. Once the application is deployed, these files can still be used for editing and updating. After an application is applied, a small layout problem can be solved through the source file. Therefore, this is an ideal parameter.
Visual Studio support
Pre-compilation is optional when you use Visual Studio 2005 to Develop ASP. NET-based applications. The publish web site menu allows you to push a website to another location as a precompiled application. In addition, the preceding check box allows you to set updatable options.
Summary
The pre-compilation options of ASP. NET 2.0 allow you to pre-compile web applications to avoid the latency of the first application call (as in General Compilation. In addition, it provides a certain degree of security, because the source code of the program is invisible in the results, and all content files can be hidden.
Developers of ASP. NET 1.x often hear users complain that initialization delays occur when applications are called for the first time. After all, the initial request will lead to a series of processes, including the initialization and Analysis of the Runtime Library, compiling the ASPX page into an intermediate language, and compiling the code of the method in real time.
Since ASP. NET became available, developers have been asking for a solution (Microsoft), while ASP. NET 2.0 provides an effective solution by using pre-compilation.