November 22, 2006

PreCompilation in ASP.Net 2.0

What is PreCompilation?
     Before looking into that, let us see, what happens in a web app when the first request arrives. When the first request for a website arrives, the worker process is started first, then the CLR initializes, all the aspx pages are parsed and compiled into intermediate language, methods are just in time compiled to native code. Due to these prcesses running , we face a performance problem, but this will not exist for the subsequent hits. In order to avoid this drawback, the all new ASP.Net 2.0 comes with a concept of PreCompilation.

     And now, what is precompilation? Using PreCompilation, we compile the website before hand and deploy it in the server, so as the first request arrives there will be not be any delay. Hence it drastically improves the performance of the website.

     There are two types of precompilation, In place Precompilation and Precompilation for deployment.

     In place precompilation eradicates the initial delay we face when your website is hit first time, while the Precompilation for deployment creates the executable version of your website, which you can deploy using FTP or XCopy.

     The aspnet_compiler.exe is the utility to precompile the web apps. To know all the available options for precompilation type aspnet_compiler /? in the .net command prompt.