Skip to main content
Email Password   helpLost your password?

Introduction

I know: the problem of pre-compiling an ASP.NET web site in order to avoid the classic "compilation delay" felt by the first user browsing those site's pages has been faced many times, and a lot of solutions have been proposed to solve it. But, when I was looking for these solutions to a classic problem, I didn't find the one that I liked completely. So, I decided to develop my own ASP.NET precompiler.

Of course, now you are thinking: "Uff, yet another pre-compile tool for ASP.NET web sites". And you're so right that I decided to title my article exactly with the words you have in your mind. But... before you stop reading, take a look at some peculiarities of the tool I propose.

Background

My starting point was the CodeProject article "Pre-Compile ASPX pages in .NET 1.1" by Narendra Naidu: there, the precompiling task was faced by simply adding to the web site a special ASP.NET page simulating an HttpWebRequest towards each ASPX page of the web site itself.

That was a nice and simple solution, but not suitable in my specific situation. In fact, I was looking for:

The ASP.NET precompiler I wrote matches all these goals, in fact:

How to use the tool

As stated before, the tool forces the compilation of ASPX files just invoking their URLs in a web request. The list of the URLs to be hit is stored in a user-editable text file, that we'll simply call "URL file". The format of the URL file is simple: it stores an URL on each line, separating with a TAB character the base URL part from the relative path of the ASPX page. This split URL paths make simpler to invoke the same set of pages on different web sites (this is useful, for example, if you have various copies of the same ASP.NET site on different environments).

To create the URL file, you can use ASP.NET precompiler itself: select the "Generate URLs" option from the "File" menu and specify: the physical location of your web site's files, the base URL that will precede the relative page path in the final URL, and the filename for your new URL file.

Generating URLs

ASP.NET precompiler will walk recursively the specified path looking for ASPX files and it will generate your URL file, that can be manually edited later (for example, to refine or limit the set of pages to be precompiled).

To make the ASP.NET precompiler less "invasive" on your site, you can adopt a trick I found in Narendra Naidu's article: by adding a Response.End() inside the pre-request event handler of Global.asax, you can abort the page processing and rendering when you call your pages with a special parameter (for example, PreCompile=true). In this way, the requests coming from ASP.NET precompiler will cause the page compilation but not the complete overhead of serving a complete web request.

  Private Sub Global_PreRequestHandlerExecute(...) _
                   Handles MyBase.PreRequestHandlerExecute
    ' Prevent processing if page was called with a "PreCompile" parameter

    If Not Request("PreCompile") Is Nothing Then Response.End()
  End Sub

If you are planning to use this trick, you'll need to check the "Include PreCompile parameter" option when generating the URLs list with ASP.NET precompiler. Also, keep in mind that the Global_PreRequestHandlerExecute() handler will be invoked for each page requested on your web application, and this might cause a little impact on the web site performance.

When the URL file is ready, before starting the pre-compilation process, you need to configure some parameters on the ASP.NET precompiler's main form:

ASP.NET Precompiler main form

The configuration settings you just set can be saved to disk for future use. The reuse of ASP.NET Precompiler settings is accomplished by the options of the "File" menu (for the storage mechanism underlying the saving/retrieval of these data, see my article about managing configuration settings persistence).

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralEntering POST Params Pin
daleallenc
8:00 30 Dec '08  
GeneralRe: Entering POST Params Pin
Alberto Venditti
4:41 9 Jan '09  
GeneralRe: Entering POST Params Pin
daleallenc
8:14 12 Jan '09  
GeneralRun from logon script or batch file Pin
daleallenc
9:12 4 Aug '08  
AnswerRe: Run from logon script or batch file Pin
Alberto Venditti
6:09 5 Aug '08  
GeneralRe: Run from logon script or batch file Pin
daleallenc
4:25 6 Aug '08  
GeneralRe: Run from logon script or batch file [modified] Pin
Alberto Venditti
4:42 6 Aug '08  
GeneralRe: Run from logon script or batch file Pin
daleallenc
4:54 7 Aug '08  
GeneralRe: Run from logon script or batch file Pin
Alberto Venditti
6:36 7 Aug '08  
GeneralRe: Run from logon script or batch file Pin
daleallenc
9:52 7 Aug '08  
GeneralRe: Run from logon script or batch file Pin
Alberto Venditti
0:35 8 Aug '08  
GeneralRe: Run from logon script or batch file Pin
daleallenc
4:12 8 Aug '08  
GeneralHow long is the precompilation valid? Pin
RC2006
14:17 7 Jul '06  
GeneralRe: How long is the precompilation valid? Pin
Alberto Venditti
3:39 10 Jul '06  
GeneralViewstate Pin
schmig
10:54 16 Aug '04  
GeneralRe: Viewstate Pin
Alberto Venditti
2:26 22 Aug '04  
General401 error Pin
Luke Geng
8:21 8 Jun '04  
GeneralRe: 401 error Pin
Anonymous
22:20 9 Jun '04  
GeneralRe: 401 error Pin
mdavisxx
7:28 28 Jun '04  
GeneralRe: 401 error Pin
Anonymous
17:06 15 Mar '05  
GeneralRe: 401 error Pin
Anonymous
17:07 15 Mar '05  
GeneralCan this be used for WebService Pin
anshuk123
8:20 3 Jun '04  
GeneralRe: Can this be used for WebService Pin
Anonymous
10:18 3 Jun '04  
GeneralRe: Can this be used for WebService Pin
Anshuk Jain
22:54 16 Jun '04  


Last Updated 24 May 2004 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009