Return to
HomePageASPNET2SecurityFAQs
Question: How do I pre-compile my ASP.NET application?
Answer:
You can pre-compile your ASP.NET application using the
aspnet_compiler.exe utility or
Publishing web site option in Visual Studio 2005. In both cases you will have to create a strong name key pair file using Strong Name (Sn.exe) utility.
Note: You can not use the password protected strong name key pair file (.pfx)
Pre-compiling your ASP.NET helps you deploy your application in production server without the original source code, identifies compile time bugs, allows you to strong name your ASP.NET application, and gives faster response time for users for first time request.
Using Visual Studio 2005 * In the Build option from the tool menu select
Publish http://localhost/.... * On the
Publish Web Site dialog box, enter the
Target Location where you want the deployable precompiled site to be copied
* Here you can choose the
"Allow this precompiled site to be updateable" check box if required, please see the note for details.
* On the
Publish Web Site dialog box, click
Ok button.
This will pre-compile the ASP.NET application and you can
XCopy the complete folder from the target location and deploy it on your production server.
Note: With updateable pre-compilation the ASPX, ASCX, ASHX, and MASTER files are copied to the target directory, you can deploy these files to the server and modify them. The ASP.NET runtime will dynamically parse and compile these files. All of the source code for code-behind files and in the App_Code folder will be compiled into assemblies and will not need to be re-deployed.
Using aspnet_compiler.exe command line utility * Open Visual Studio 2005 command Prompt
* Run the following command, specifying applications virtual path and target directory.
aspnet_compiler -v /<<ASP.NET Application Virtual path>> <<Target Directory Path>>
* For updateable pre-compilation include the -u switch in the command as follows
aspnet_compiler -v /<<ASP.NET Application Virtual path>> <<Target Directory Path>> -u
This will pre-compile the ASP.NET application and you can
XCopy the complete folder from the target location and deploy it on your production server.
UPDATE: Also look at Visual Studio Web Deployment Projects - http://msdn.microsoft.com/asp.net/reference/infrastructure/wdp/default.aspx
Return to
HomePageASPNET2SecurityFAQs