| Details | ![]() |
| QuickDocId | 256 |
| Written by | Imar Spaanjaars |
| Posted | 02/29/2004 17:36 |
| Reviewed | 12/06/2006 15:29 |
| Page views | 1729 |
| Listened to | Saturday Morning by Eels (Track 2 from the album: Shootenanny!) |
Are you looking to hire an experienced software developer or .NET consultant? Then get in touch with me through my company's web site at devierkoeden.com
Found an interesting article on this site? Got inspired by something you read here? Then consider making a donation with PayPal.
UPDATE (2005-12-06): The compilation features presented in this article are obsolete. It's recommended that you look at Web Deployment Projects (http://weblogs.asp.net/scottgu/archive/2005/11/10/430283.aspx) instead.
Unlike Web sites created with Visual Studio .NET 2002 or 2003, there is no need to do a full compile of the project whenever something has changed in your site. The new Code Behind feature and the Code directory used in ASP.NET Whidbey allow you to make changes without recompiling. As soon as the changed page gets requested, the .NET FRamework will recompile the page on the fly.
However, it is sometimes useful to compile the application right after you have deployed it. One reason for this precompilation is speed. Another is code protection. A compiled application does not expose its source in the ASPX pages any longer. There are two ways to compile an application at deployment time: In-place compilation and Precompilation for Deployment
Compilation for Deployment requires you to use a command line utility called aspnet_compiler. To run this utility, follow these steps:
aspnet_compiler /v /YourWebsiteName -p C:\Inetpub\wwwroot\YourSite
C:\Inetpub\wwwroot\YourSiteCompiled
In this command, YourWebsiteName is the name of your Web site as you see it in the Internet Information Services management console.
As you can see, I passed both the source folder (C:\Inetpub\wwwroot\YourSite) and the output folder (C:\Inetpub\wwwroot\YourSiteCompiled) as command line parameters. If you want, you can leave out the -p parameter and the filename for the source path. In that case, the tool will try to find the physical location of the Web site itself. For this to run, the Web site needs to be located below the Default Web site (under /LM/W3SVC/1/Root in the IIS MetaBase). There is no need to create the output folder; the utility will create the folder for you if it doesn't exist yet.
As soon as the program is ready, take a look in the output folder. You'll find a Bin folder that contains a bunch of DLLs required for the app. You can also see that all your ASPX have decreased in size and are now all less than 1k. That's because they no longer include any source. These files are really just placeholders. At run-time, code in the DLLs in the Bin folder is run instead, serving up the right page for your requests.
By precompiling your application you can prevent people from viewing or modifying your source. All code is now hosted in DLLs and no longer in easy viewable ASPX pages. However, you can no longer do any "quick fixes" on the server. You'll need the original source to make any changes, even if you just want to change some simple HTML markup.
Wonder where to go next?
You can post a comment on this article.
Consider making a donation
Please consider making a donation using PayPal. Your donation helps me to pay the bills so I can keep running Imar.Spaanjaars.Com, providing fresh content as often as possible.
| QuickDocId | 256 |
| Full URL | http://imar.spaanjaars.com/256/how-do-i-precompile-an-aspnet-whidbey-application |
| Short cut | http://imar.spaanjaars.com/256/ |
| Written by | Imar Spaanjaars |
| Date Posted | 02/29/2004 17:36 |
| Date Last Reviewed | 12/06/2006 15:29 |
| Listened to when writing | Saturday Morning by Eels (Track 2 from the album: Shootenanny!) |
Talk Back! Comment on Imar.Spaanjaars.Com
I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article. The Talk Back feature is not meant for technical questions that are not directly related to this article. So, a post like "Hey, can you tell me how I can upload files to a MySQL database in PHP?" is likely to be removed. Also spam and unrealistic job offers will be deleted immediately.
When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you. It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button.
If you want to object to a comment made by another visitor, be sure to contact me and I'll look into it ASAP. Don't forget to mention the page link, or the QuickDocId of the document.
For more information about the Talk Back feature, check out this news item.
Whoooops!!
Unfortunately, something went wrong and your message or comments have not been submitted successfully.
There's a fair chance things broke down because you tried to post something that looks like HTML. Things that look HTML include (X)HTML, obviously, XML, ASP.NET markup and c# generics syntax as all of them use the < and > characters.
If that's the case, try altering your message and remove anything that looks like an angled bracket. You can replace them with [ and ] for example so you can still make it look like HTML to some extend.
If, on the other hand, you were trying to spam this web site, I am pretty glad I caught you in the act and stopped you from doing so ;-)
The number you entered is not correct. Please enter the sum of the two numbers again.