Sdílet prostřednictvím


Building (Compiling) Web Site Projects

You can build (compile) the current page or your entire Web site project at any time to help find compile-time errors. Building performs tasks such as the following:

  • Compiles the code in one page or all pages in the site.

  • Compiles the code in the App_Code folder.

  • Compiles code in the Global.asax file.

  • Resolves and, if necessary, compiles any dependent resources.

  • Parses Web.config files to look for invalid configuration elements.

In short, building a Web site performs the same compilation tasks that occur when a page is requested in the browser. However, the resulting object code is not used to run the page.

Building Individual Pages

You can also build individual pages. In that case, Visual Studio compiles only the current page and its dependencies. You might find this useful if your site contains many unfinished pages and you do not want to be notified of errors in any page but the one you are currently working with. You can set options for what to build by setting project options. For details, see How to: Test Web Pages in Visual Web Developer.

Building versus Precompiling

Building a page or Web site is part of developing a site, and is intended to help you find compile-time errors that might occur anywhere in the site. Although building does compile the pages, it does not produce an assembly that you deploy. You can deploy a Web site project without building (compiling) it. When users request pages from the production server, ASP.NET will dynamically compile the site, effectively performing the same steps that the build process does in Visual Studio. (ASP.NET caches the resulting output so that the pages do not need to be recompiled with each request.)

If you want to compile the site into assemblies and other files that you can deploy, you can precompile the site or you can use a Web application project instead of a Web site project. For information about precompiling and deployment, see Web Deployment Content Map for Visual Studio and ASP.NET. For information about the differences between Web site projects and Web application projects, see Web Application Projects versus Web Site Projects in Visual Studio.

See Also

Other Resources

Web Application Projects versus Web Site Projects in Visual Studio

Web Deployment Content Map for Visual Studio and ASP.NET

Testing Web Pages in Visual Studio

How to: Test Web Pages in Visual Web Developer