<

[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x

Precompile an ASP .net website and publish it without source code or markup

Published on
10,518 Points
4,518 Views
Last Modified:
If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is requested for the first time after restart.   You can avoid this first-time-access compilation by deploying your web application in a precompiled state!

Precompile your web application before deployment

When you precompile your web application the following takes place:

All markup files (.aspx) are stripped of their content
All web service files (.asmx) are stripped of their content
All code-behind files (.cs) are removed
All user control files (.ascx) are removed

This means that you will be able to deploy your website entirely without readable markup or source code.

You still need all the markup files in the correct places, but they will no longer contain any actual markup.  So, in the future you won't have to worry about updating .aspx files - unless new ones have been added to the web application.

How to precompile your website

In order to precompile your web application you need to use a simple command prompt command. If you wanted you could add this command to a post-build event to automate the process.

The precompilation is carried out by the aspnet_compiler executable located in your .NET installation folder. If you run the Visual Studio command prompt you won't have to worry about that though - the path variable is then set so that you can execute the aspnet_compiler executable regardless of what folder you are in.

If you use the standard command prompt (cmd) you'll have to switch to the correct .NET installation folder, for example:

cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

Open in new window

Example:  Let's say I have a website located in C:MyWebSite. In order to precompile this website I use aspnet_compiler and specify a target folder for the precompiled output:

aspnet_compiler -p C:MyWebsite -v / C:MyPrecompiledWebsite

Open in new window

The  C:MyPrecompiledWebsite will now contain a precompiled version of the web application. All markup and web service files will now be empty.

You are now ready to deploy!

If you want more information visit the below link:

    ASP.NET Web Site Precompilation  
    http://msdn.microsoft.com/en-us/library/ms228015(VS.85).aspx
0
Comment
Author:manunadh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
0 Comments

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Join & Write a Comment

Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month