I\'m working on a website that I\'d like to use in-place compilation on in order to make the first hit faster. I\'d like to use the ClientBuildManager.CompileFile method to do
I think that what you're seeing is actually unrelated to the use of CompileFile
vs PrecompileApplication
. i.e. if you were to do the same thing but call PrecompileApplication()
, you still would get a folder mismatch.
Note that technically, you are not creating the CBM object correctly. The correct way of calling it is to rely on IIS information to locate the files. To do this:
/LM/W3SVC/7/ROOT/
for appVirtualDir
appPhysicalSourceDir
Note that the '7' is just an example. To get the correct number:
/LM/W3SVC/ID/ROOT/
I'm explaining this for the record, because unfortunately, I was not able to get the folders to match even in this way. It's possible that this scenario is just broken in ASP.NET (it used to work!).
An alternate possibility is to do it server side. e.g.
BuildManager.GetCompiledType("~/myfile.aspx")
, and similar calls for each page (or user control, etc) that you want to precompile.Of course, there is also the low tech alternative of simply requesting the pages you want compiled ahead of time to warm up your site.