JavaScript Editor jscript editor     Web designer 



Main Page

You can precompile an ASP.NET Web site, which offers the following benefits:

You can precompile a site to get these benefits for a site that is already on a production server.

You can also precompile a Web site for deployment, which creates a layout containing assemblies and other information that you can then copy to a production server. In addition to the benefits listed above, a Web site that is precompiled for deployment gives you the ability to create a compiled version of the site that can be deployed to a production server without source code.

The procedures in this topic use the switches and parameters of the Aspnet_compiler.exe tool. For more information about this tool, see ASP.NET Compilation Tool (Aspnet_compiler.exe).

For more information about precompilation, see ASP.NET Web Site Precompilation Overview.

To precompile an ASP.NET Web site in place

  1. Open a command window and navigate to the folder containing the .NET Framework.

    The .NET Framework is installed in the following location.

    В CopyCode imageCopy Code
    %windir%\Microsoft.NET\Framework\version
  2. Run the aspnet_compiler command by typing the following at a command prompt.

    В CopyCode imageCopy Code
    aspnet_compiler -v /virtualPath

    The virtualpath parameter indicates the Internet Information Services (IIS) virtual path of your Web site.

    —or—

    If your Web site is not an IIS application and therefore has no entry in the IIS metabase, type the following command at a command prompt.

    В CopyCode imageCopy Code
    aspnet_compiler -p physicalOrRelativePath -v /

    In this case, the physicalOrRelativePath parameter refers to the fully qualified directory path in which the Web site files are located, or a path relative to the current directory. The period (.) operator is allowed in the physicalOrRelativePath parameter. The -v switch specifies a root that the compiler will use to resolve application-root references (for example, with the tilde (~) operator). When you specify the value / for the -v switch, the compiler will resolve the paths by using the physical path as the root.

To precompile an ASP.NET Web site for deployment

  1. Open a command window and navigate to the folder containing the .NET Framework.

    The .NET Framework is installed in the following location.

    В CopyCode imageCopy Code
    %windir%\Microsoft.NET\Framework\version
  2. Run the aspnet_compiler command, specifying the source as either a virtual path or physical path, the target folder, and a switch indicating whether you want to compile both code and .aspx pages (which is the default) or just code.

    В CopyCode imageCopy Code
    aspnet_compiler -v virtualPath targetPath

    If your Web site is not an IIS application and therefore has no entry in the IIS metabase, use the following value for the -v switch.

    В CopyCode imageCopy Code
    aspnet_compiler -p physicalOrRelativePath -v / targetPath

    If you want to precompile the site for deployment and update, include the -u switch, as shown in the following code example.

    В CopyCode imageCopy Code
    aspnet_compiler -p physicalOrRelativePath -v / targetPath -u

    The targetPath parameter is a physical path.

See Also

Reference

ASP.NET Compilation Tool (Aspnet_compiler.exe)

Concepts

ASP.NET Web Site Precompilation Overview
File Handling During ASP.NET Precompilation



JavaScript Editor jscript editor     Web designer