views:

2301

answers:

2

If you precompile a web site and keep it updatable, the ASP.NET parser can see from the Page directive that there is no codefile or codebehind and where to find the base class (inherits attribute).

<%@ page language="C#" autoeventwireup="true" inherits="_Default, Precompiled" theme="Default" validaterequest="false" %>

If the site is precompiled and not updatable, the .compiled files in the bin folder should give the ASP.NET runtime all the necesary information on how to instantiate the page classes.

So why is the precompiledApp.config needed?

Thanks!

+2  A: 

It's used to indicate whether or not the ASPX/ASCX pages in your site are updateable or not. You can precompile and have the code behind compiled, but leave these pages updateable so you can make minor GUI-related tweaks should you wish.

Nissan Fan
I understand the concept of precompiling and the updatable option. But why is the precompiledApp.config file needed?
michielvoo
Because ASP.NET by default will try to compile all files (including code-behinds) in the directory of an .ASPX page request along with App_Code and over files marked to be build if it doesn't find this file. If it finds a .precompiledApp.config file it will look into it and determine whether or not to still compile the ASPX files since they could be allowed to be updatable.
Nissan Fan
Based on some experiments I believe that the file serves no purpose. You can precompile a site, allow it to be updatable and then replace one page with the original including its code file and both will be compiled. The precompiledApp.config does not determine wether or not pages are compiled, this seems to only be determined based on the page directive.It may differ when updatable is false, but I have not tested that.
michielvoo
A: 

Find a comfortable place to sit and read this:

Codebehind and Compilation in ASP.NET 2.0 Fritz Onion

rick schott
From that article: "The PrecompiledApp.config file is used to keep track of how the app was deployed and whether ASP.NET needs to compile any files at request time."Wether ASP.NET needs to compile any files at request time can be determined by checking the Page directive or the .compiled files in the Bin folder, right? So why exactly is the precompiledApp.config file needed?
michielvoo
How do you mark you site is updatable when pre-compiling? This is a marker file, that isn't always technically needed, however sometimes it is. I think this file is Microsoft's way of trying to hold your hand. I personally don't deploy this way.
rick schott