C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Precompiling ASP.NET 2.0 websites


Posted Date: 27 Aug 2007    Resource Type: Articles    Category: .NET Framework

Posted By: Kamal       Member Level: Gold
Rating:     Points: 20



ASP.NET 2.0 provides the ability to precompile websites into binaries before deploying them to the server. This has been a desired feature in the past and in this article we will see how simple it is to do so using ASP.NET 2.0.

When a page is first requested from the server, the page is compiled by ASP.NET and then served. Even though one may argue that it does not take a long time for the compilation process to execute, however for sites which are updated frequently, it could lead to some first-time overheads issues.

ASP.NET 2.0 introduces the option of precompiling your site. This offers the following advantages :
1. You do not need to deploy the source code to the server. The website is precompiled into binaries, which is then deployed to the server.
2. It allows you to identify bugs first hand, during compilation.
3. Makes the deployment process a lot easier as all your aspx pages, user controls etc. are compiled into binaries.

There are two ways in which we can precompile a website.
Precompiling websites through command-line
To precompile a website using the command line, follow these steps :
1. Navigate to the directory C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727.

2. Run the aspnet_compiler command in the command prompt by typing:
aspnet_compiler -p -v /

For e.g. let us assume that your website ‘Sampleweb1’ is stored at ‘C:\Websites’. To compile this website, you will type the following at the command prompt :

aspnet_compiler – p C:\Websites\SampleWeb1 –v /MyFirstWebsite C:\Projects\Samples

where :
· C:\Websites\SampleWeb1 - is the physical path to your website
· /MyFirstWebsite – is the virtual directory used at runtime
· C:\Projects\Samples – is the destination directory.

3. After the command has been run, open the C:\Projects\Samples directory to find a bin directory with the .dll and .compiled files.

Note: All your images, .css, .htm etc are not compiled into binaries. They are just copied to the target folder.

Precompile and publish websites using Visual Studio 2005
To precompile and publish your website using Visual Studio, follow these steps:
1. Open your website using Visual Studio.
2. Go to the Build Menu > Publish Web Site.
3. You get a Publish Web Site dialog where you can specify the path to publish to. Clicking on the eplisis(…) gives you the option of choosing your website output to File System, IIS, FTP or a remote site.
4. Select your options in the dialog :

a. Allow this precompiled site to be updatable – This option allows you to change the markup and client side functionality of the .aspx pages. However you cannot access the server side code.
b. Use Fixed Naming And Single Page Assemblies – This option is not available for in place compilation. It turns off batch builds during precompilation to generate dll’s with fixed names.
c. Enable strong naming on precompiled assemblies – This option specifies that your assemblies are strong named using a key file or container.

5. Click Ok to compile and publish the website.




Responses

Author: Vasudevan Deepak Kumar    17 Sep 2007Member Level: Diamond   Points : 0
A few people have been extended support for 1.0 and 1.1. Check these out:

1) http://www.codeproject.com/aspnet/ASPdotNETprecompiler.asp
2) http://www.codeproject.com/aspnet/PreCompileAspx.asp


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Tips for Master Page
Previous Resource: ASP.NET HyperLink & Mailto In Details View
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use