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

AID: 3666
  • Status: Published

1620 points

  • Bymanunadh
  • TypeTips/Tricks
  • Posted on2010-09-08 at 02:45:39
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
                                    
1:

Select allOpen 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
                                    
1:

Select allOpen 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
Asked On
2010-09-08 at 02:45:39ID3666
Tags

Introduction to building versus precompiling

Topic

Windows XP Operating System

Views
1046

Comments

Add your Comment

Please Sign up or Log in to comment on this article.

Join Experts Exchange Today

Gain Access to all our Tech Resources

Get personalized answers

Ask unlimited questions

Access Proven Solutions

Search 3.2 million solutions

Read In-Depth How-To Guides

1000+ articles, demos, & tips

Watch Step by Step Tutorials

Learn direct from top tech pros

And Much More!

Your complete tech resource

See Plans and Pricing

30-day free trial. Register in 60 seconds.

Loading Advertisement...

Top Windows XP Experts

  1. nobus

    109,514

    Master

    0 points yesterday

    Profile
    Rank: Savant
  2. MASQUERAID

    86,680

    Master

    498 points yesterday

    Profile
    Rank: Genius
  3. flubbster

    83,880

    Master

    2,000 points yesterday

    Profile
    Rank: Genius
  4. thinkpads_user

    44,689

    1,500 points yesterday

    Profile
    Rank: Genius
  5. BillDL

    43,868

    0 points yesterday

    Profile
    Rank: Genius
  6. Run5k

    41,750

    0 points yesterday

    Profile
    Rank: Genius
  7. Darr247

    38,180

    0 points yesterday

    Profile
    Rank: Genius
  8. SSharma

    36,782

    0 points yesterday

    Profile
    Rank: Genius
  9. ve3ofa

    34,109

    0 points yesterday

    Profile
    Rank: Genius
  10. cwstad2

    32,527

    0 points yesterday

    Profile
    Rank: Guru
  11. motnahp00

    29,474

    3,000 points yesterday

    Profile
    Rank: Sage
  12. DTHConsulting

    28,336

    0 points yesterday

    Profile
    Rank: Guru
  13. Anuroopsundd

    26,827

    2,000 points yesterday

    Profile
    Rank: Sage
  14. hanccocka

    26,512

    0 points yesterday

    Profile
    Rank: Genius
  15. arnold

    26,147

    0 points yesterday

    Profile
    Rank: Genius
  16. KCTS

    25,512

    0 points yesterday

    Profile
    Rank: Genius
  17. l33tf0b

    22,780

    0 points yesterday

    Profile
    Rank: Wizard
  18. rindi

    22,108

    0 points yesterday

    Profile
    Rank: Savant
  19. dstewartjr

    21,650

    0 points yesterday

    Profile
    Rank: Genius
  20. Callandor

    21,288

    0 points yesterday

    Profile
    Rank: Genius
  21. DaveBaldwin

    21,060

    0 points yesterday

    Profile
    Rank: Genius
  22. leew

    20,982

    0 points yesterday

    Profile
    Rank: Savant
  23. garycase

    20,824

    0 points yesterday

    Profile
    Rank: Genius
  24. rpggamergirl

    20,432

    10 points yesterday

    Profile
    Rank: Genius
  25. jcimarron

    19,748

    0 points yesterday

    Profile
    Rank: Genius

Hall Of Fame