The file '/xxx/xxx.aspx' has not been pre-compiled, and cannot be requested
Customer has a pre-compiled web site and it works fine unless access a web service inside a virtual directory under root application of this web site. Every time access this web service, ASP.NET throws out following exception saying this is not a pre-compiled web site.
Exception type: HttpException
Exception message: The file '/child/default.aspx' has not been pre-compiled, and cannot be requested.
Request URL: https://precompile/child/default.aspx
Request path: /child/default.aspx
Stack trace: at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
Well, why we see this exception as this is a pre-compiled site already?
Look at the files under root directory, the contents of ASPX are something like “This is a marker file generated by the precompilation tool, and should not be deleted!”. This means the site has been precompiled and not updatable.
Then, look at the ASMX file under problematic virtual directory, and the contents are different, it just contains source code like below. This means this virtural directory was published with allow updatable option, and ASP.NET need to compile the ASMX file when first request coming in.
“<%@ WebService Language="C#" CodeBehind="~/App_Code/WebService.cs" Class="WebService" %>”.
By looking at the code of System.Web.Compilation.BuildManager in Reflector, we understand the “not pre-compiled exception” will only throw when ASP.NET need to compile a page like ASPX, ASMX, ASCX but this application is not updatable.
Now, the cause is clear. This virtural direcotry was published with allow update, but the root of this site was published as not updatable. Since this is a virtural directory, not a web application, it inherits the configure from root application, and in another word, it is not updatable as well.
The solution is either convert the virtural directory to a web application, so it has it’s own AppDomain and configuration. Or publish the root application as updatable as well.