Search code examples
asp.netiis-7

Compilation Error after Successful Publish of ASP.NET(4.0) Web Application


My Web Application builds and publishes successfully, the problem arises after copying the files to the web server, where I get a compilation error when I try to browse to several pages, other pages however continue to function correctly.

My first thought that was some of the files may not have been successfully copied so I republished and tested the page and all seemed well until I checked a different page that had been working with the previous publish that was now exhibiting the same problem subsequent publishing have seen similar effect with the pages affected altering each time.

The pages that are failing on the web server have previously been functional on the web server have not been altered for this publish and continue to work fine in Visual Studio 2010 Debug.

I have recycled the application pool restarted the website and rebooted the server.

The error from our error logs is:

GAE:: System.Web.HttpException (0x80004005): The file /XXXX.aspx has not been pre-compiled, and cannot be requested.     
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)     
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)     
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)     
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)     
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)     
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

EDIT: I have copied the source aspx and cs files for one of the failing pages (renaming the class) and re published it the solution. The new page works side by side with its failing counterpart.


Solution

  • This error can be a red herring and usually masks the real error.

    1st check permissions on the IIS app, physcial directory and the affected file are correct.

    If it's not permissions, set custom errors to RemoteOnly on the webserver only and re-publish. In the .net 4, publish the app with the following options ticked, "allow pre compiled site to be updateable" and "use fixed naming conventions and single page assemblies"

    When deployed to the webserver you should find the correct issue reported now, which will be a missing custom or 3rd party assembly, this may be recently added and removed, or a blast from the past which has reared its head again for no apparent reason (this was our issue, assembly not used in any forms, but was defined in the config file and hence took several forms down)

    Hope this helps you to solve your issue - good luck!