Email Aaron Blake now at webmaster@aaronblake.co.uk
or contact me

Precompiling ASP.net Web Site Projects in Visual Studio 2008

Introduction

This tutorial will show you how to precompile an ASP.net Web Site Project in Visual Studio 2008.

ASP.net currently has 3 different project models:

  1. Web Site Projects
  2. Web Application Projects
  3. MVC Projects

Unlike Web Application and MVC projects, Web Site Projects do not need to be precompiled before they can be deployed on the web server. ASP.net dynamically compiles the site on Application start which means websites can be deployed quicker. The disadvantage is the user will experience delays every time the site needs to recompile on the server.

To overcome this problem, you can precompile a Web Site Project in Visual Studio 2005 upwards (excluding Visual Web Developer) before you upload it to the web server.

Steps

  1. Open or create a new website project in Visual Studio.
  2. Go to Build > Publish Web Site
  3. In the Target Location text box, enter where you would like to save the precompiled site.
  4. Leave the default values how they are, unless you wish to customise the build.
  5. Press OK.
  6. Visual Studio will build and save the entire pre-compiled website in the location you selected.
  7. Simply upload this to your web server as you would normally do.

Notes

Warning: Make sure you delete the App Code folder on your web server if one already exists. If you have a class file in the App Code folder that has the same class as one on a precompiled site, you will get an error as both will be referenced in the project.

Further reading

For more information, please see:
How to: Precompile ASP.NET Web Sites

Post a Comment

You must be logged in to post a comment.

Email me through this magic form.