Sideway
output.to from Sideway
Draft for Information Only

Content

ASP.NET Web Site Precompilation Overview
 Precompilation Options
 In-Place Precompilation
 Precompilation for Deployment
  Precompiling for Deployment Only
  Precompiling for Deployment and Update
 Precompiling Child Applications
 Performing Precompilation
 See Also
   Tasks
   Concepts
 Sources and References

ASP.NET Web Site Precompilation Overview

By default, ASP.NET Web pages and code files are compiled dynamically when users first request a resource such as a page from the Web site. After pages and code files have been compiled the first time, the compiled resources are cached, so that subsequent requests to the same page are extremely efficient.

ASP.NET can also precompile an entire site before it is made available to users. This provides a number of advantages, including:

  • Faster response time for users, since pages and code files do not have to be compiled the first time they are requested. This is particularly useful on large sites that are updated frequently.

  • A means to identify compile-time bugs before users see a site.

  • The ability to create a compiled version of the site that can be deployed to a production server without source code.

Precompilation Options

ASP.NET offers two options for precompiling a site:

  • Precompiling a site in place. This option is useful for existing sites where you want to enhance performance and perform error checking.

  • Precompiling a site for deployment. This option creates a special output that you can deploy to a production server.

Additionally, you can precompile a site to make it read-only or updatable. The following sections provide more details about each option.

In-Place Precompilation

You can enhance the performance of your Web site somewhat by precompiling it. This is particularly true in sites where there are frequent changes and additions among ASP.NET Web pages and code files—in a fluid Web site, the extra time required to dynamically compile new and changed pages can affect the users' perception of the site's quality.

NoteNote

Precompiling a site in place effectively performs the same compilation that occurs when users request pages from your site. Therefore, the primary performance improvement is that pages do not have to be compiled for the first request.

When you perform in-place precompilation, all ASP.NET file types are compiled. (HTML files, graphics, and other non-ASP.NET static files are left as is.) The precompilation process follows the same logic that ASP.NET uses for dynamic compilation, accounting for dependencies between files. During precompilation, the compiler creates assemblies for all executable output and places them in a special folder under the %SystemRoot%\Microsoft.NET\Framework\version\Temporary ASP.NET Files folder. Thereafter, ASP.NET fulfills requests for pages from the assemblies in this folder.

If you precompile the site again, only new or changed files are compiled (or those with dependencies on new or changed files). Because of this compiler optimization, it is practical to compile the site after even minor updates.

Precompilation for Deployment

Another use for precompiling a site is to produce an executable version of the site that can be deployed to a production server. Precompiling for deployment creates output in the form of a layout that contains assemblies, configuration information, information about the site's folders, and static files (such as HTML files and graphics).

After compiling the site, you can deploy the layout to a production server using tools such as the Windows XCopy command, FTP, Windows installation, and so on. Once the layout is deployed, it functions as the site, and ASP.NET fulfills requests for pages from the assemblies in the layout.

Precompiling a site for deployment provides a measure of protection for your source code and other intellectual property. For more information about how the compiler works with files during compilation for deployment, see File Handling During Site Compilation for Deployment.

You can precompile for deployment in two ways: precompiling for deployment only, or precompiling for deployment and update.

Precompiling for Deployment Only

When you precompile for deployment only, the compiler produces assemblies from virtually all ASP.NET source files that are normally compiled at run time. This includes program code in pages, .cs and .vb class files, other code files, and resource files. The compiler removes all source and markup from the output. In the resulting layout, compiled files are generated for each of the .aspx files (with the extension .compiled) that contain pointers to the appropriate assembly for that page.

To change the Web site, including the layout of pages, you must change the original files, recompile the site, and redeploy the layout. The only exception is the site configuration; you may make changes to the Web.config file on the production server without having to recompile the site.

This option provides the greatest degree of protection for your pages and the best performance at startup.

Precompiling for Deployment and Update

When you precompile for deployment and update, the compiler produces assemblies from all source code (except page code in single-file pages) and from other files that normally produce assemblies, such as resource files. The compiler converts .aspx files into single files that use the compiled code-behind model and copies them to the layout.

This option enables you to make limited changes to the ASP.NET Web pages in your site after compiling them. For example, you can change the arrangement of controls, colors, fonts, and other appearance aspects of pages. You can also add controls, as long as they do not require event handlers or other code.

When the site runs the first time, ASP.NET performs further compilation in order to create output from the markup.

NoteNote

A precompiled updatable site does not allow multiple pages to reference the same CodeFile class.

Precompiling Child Applications

Precompiling a Web site compiles only that site, not any child sites. If a Web site contains a child folder that is marked as an application in IIS, the child application is not compiled when you precompile the parent folder.

Performing Precompilation

You can precompile a Web site using the Aspnet_compiler.exe tool on the command line. For more information, see How to: Precompile ASP.NET Web Sites for Deployment and ASP.NET Compilation Tool (Aspnet_compiler.exe).

Some visual designers such as Visual Studio include commands to precompile a Web site from within the IDE. For more information, see How to: Publish and Sign Assemblies for Precompiled Web Sites in Visual Web Developer and How to: Publish and Generate Fixed Assembly Names in Visual Web Developer and How to: Publish Web Sites (Visual Studio) and How to: Publish and Sign Assemblies for Precompiled Web Sites in Visual Web Developer and How to: Publish and Generate Fixed Assembly Names in Visual Web Developer and How to: Publish and Sign Assemblies for Precompiled Web Sites in Visual Web Developer and How to: Publish and Generate Fixed Assembly Names in Visual Web Developer and How to: Publish Web Sites and How to: Publish Web Sites.

One coding restriction applies in sites that you intend to compile with source protection enabled. It is possible for a base page class (a code-behind class) to reference the associated page class (.aspx file) and page class members using a fully qualified class name. However, this type of reference will not work when precompiling your site with source protection enabled. This is because the base page class from the code-behind file is not located in the same assembly as the page class derived from the .aspx page. For more information on precompilation with source protection enabled, see How to: Sign Assemblies for Precompiled Web Sites.

See Also

Tasks

How to: Precompile ASP.NET Web Sites for Deployment

Concepts

File Handling During ASP.NET Precompilation

Sources and References

https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-3.0/399f057w(v=vs.85)

©sideway

ID: 211100024 Last Updated: 11/24/2021 Revision: 0 Ref:

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019