This article describes the use of ASP.net 2.0 precompilation to effectively address the initialization latency problems that developers encounter when they first invoke an application.
Developers of ASP.net 1.x often hear users complaining about the initialization delay when they first invoke the application. After all, the initial request raises a series of processes, including runtime initialization, parsing, compiling ASPX pages into intermediate languages, compiling the method Just-in-time, and so on.
Since ASP.net, developers have been asking for a solution, and ASP.net 2.0 uses precompilation to provide an effective solution.
Pre-compiling options
When the application is first started, ASP. NET dynamically analyzes and compiles all the asp.net files (aspx pages). The running environment buffers the results of the compilation to better serve all future requests.
Starting an application for the first time after a server reboot or a Web server reboot means that the process will start again. Also, changes to any file of an application are detected by the system, and the first time the application is run after the file has changed will make the process happen again.
Many Web developers hate this kind of initialization latency. Precompilation avoids this delay by compiling the application (in advance).
Command line
By installing in the. NET Framework 2.0, the Aspnet_compiler.exe program can initiate precompilation. It is located under the Framework installation directory (the version number varies according to the version of the installed frame). The following is the default path for this program:
C:\\microsoft.net\framework\v2.0.5072\aspnet_compiler.exe
You can use-? This command parameter to view all of the program's parameter list, let me explain some of the available parameters:
M: This parameter indicates that you will use the complete IIS metabase path that the application will be precompiled. The path to the IIS metabase is the/lm/w3svc/1/root/application name.
V: Use the virtual IIS path that requires precompiling the Web application. The format of the virtual path is:/Application name.
P: Use the physical IIS path that requires precompiling the Web application. It is the full path that includes the drive name and points to the application directory. For example, c:\inetpub\wwwroot\ the application name. V This parameter must be used with p, so the compiler can parse any application's root reference.
F: Indicates whether the target directory is to be overwritten.
U: Applications used to set up precompilation are updatable. This means that all tag files (ASPX, ascx, and so on) can be updated in the target directory.
TargetDir: The target directory used to precompile application files.
The following command compiles an application with the virtual path and the specified target path:
ASPNET_COMPILER.EXE–V/Application name c:\ target directory name.
If you do not specify a target directory, the resulting file is placed in the asp.net temporary file directory, just as the ASP.net runtime handles the compilation the first time the application is invoked. The default path for the temporary directory is as follows:
c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary asp.net files\ application name
Another benefit of precompiling is the ability to capture any errors that occur during the startup phase of the application. Errors are displayed in the tool, but the compilation process is not terminated.