成功发布 ASP.NET(4.0) Web 应用程序后出现编译错误
我的 Web 应用程序构建并发布成功,将文件复制到 Web 服务器后出现问题,当我尝试浏览多个页面时出现编译错误,但其他页面继续正常运行。
我的第一个想法是某些文件可能尚未成功复制,因此我重新发布并测试了该页面,一切似乎都很好,直到我检查了与先前发布一起使用的另一个页面,该页面现在表现出相同的问题,后续发布有看到类似的效果,受影响的页面每次都会发生变化。
在 Web 服务器上出现故障的页面以前在 Web 服务器上可以正常工作,但在此发布中未进行任何更改,并且在 Visual Studio 2010 调试中继续正常工作。
我已经回收了应用程序池并重新启动了网站并重新启动了服务器。
我们的错误日志中的错误是:
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)
编辑:我已复制其中一个失败页面的源 aspx 和 cs 文件(重命名该类)并重新发布解决方案。新页面与失败的对应页面并存。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
此错误可能会转移注意力,并且通常会掩盖真正的错误。
第一次检查 IIS 应用程序、物理目录和受影响文件的权限是否正确。
如果不是权限问题,请仅在网络服务器上将自定义错误设置为 RemoteOnly 并重新发布。在 .net 4 中,发布应用程序并勾选以下选项,“允许预编译站点可更新”和“使用固定命名约定和单页程序集”
部署到网络服务器时,您应该会发现现在报告的正确问题,其中将是一个缺失的自定义或第 3 方程序集,这可能是最近添加和删除的,或者是过去的一次爆炸,没有明显的原因再次抬起头(这是我们的问题,程序集未以任何形式使用,但已定义)在配置文件中,因此采取几个表格)
希望这可以帮助您解决您的问题 - 祝您好运!
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!
我在 VS2017 和一个已经运行很长时间的应用程序中遇到了同样的问题。
该应用程序过去通过 XCOPY 部署进行部署,无需发布。切换到发布方法后,出现错误。
经过一番研究,我们发现在生产中,web.config 中仍然有一个配置文件条目,但它在开发中已被删除,因为不再需要它了。
取消注释 web.config 中的节点配置文件后,应用程序已启动并运行。
在部署时,我们还删除了除 APP_DATA 和 web.config 之外的所有文件。
I ran into the same problem with VS2017 and an application that was already running for a long time.
The application used to be deployed thru XCOPY deployment without publishing. After switching to the publishing method the error showed up.
After some reasearch we found that in the production there was still an entry for profiles in the web.config while it had already been removed in developement since there was no need vor it anymore.
After uncommenting the node profiles in web.config the application was up and running.
While deploying we had also remove all files except APP_DATA and web.config.
可能与文件或 IO 相关。您是否复制了所有文件,而不仅仅是二进制文件?您可以尝试删除所有旧文件(首先备份),这样就不会出现写保护或安全问题。
Propably file or IO related. Did you copy all the files, not just binaries? You could try deleting all the old files (backup first) so it´s not some write protection or security issue.
我有同样的问题。
有些页面在发布后尝试打开时会抛出错误。
对我有用的一个解决方案是..当我检查那些显示错误的aspx文件时,有CodeFile而不是CodeBehind...
我从CodeFile更改为CodeBehind并且工作正常。 (不知道这是否是 CodeBehind 在 bin 目录中单独可用的原因。我是一个新手,可能这个原因不正确。如果我错了,请纠正我)
但问题是,在本地主机上,某些文件在运行时会抛出错误保留为代码隐藏。
I had the same issue.
Some of the pages throw error when trying to open after publishing them.
One solution which worked for me was .. When I checked the aspx files of those showing errors, had CodeFile and not CodeBehind...
I changed from CodeFile to CodeBehind and it worked fine. (Dont know if its a reason that CodeBehind alone available in the bin directory.. Am a newbie and may be this reason is not right. Please correct me if I was wrong)
But problem is, on localhost certain files throw error when they are left as CodeBehind.
我认为这个线程可能相关:
如何修复 ASP.NET 错误“文件'nnn.aspx' 尚未预编译,无法请求。"?
正如此处所示,我们的解决方案是删除以下所有文件:
I think this thread may be related:
How to fix ASP.NET error "The file 'nnn.aspx' has not been pre-compiled, and cannot be requested."?
As indicated there, our solution was to delete all the files under:
我知道这个问题很旧,但如果有人遇到这个问题,在使用版本、文件等之前,我可以建议先清理项目吗?经过紧张的一天后,这解决了我的问题。
I know this issue is old but if anyone comes into this problem, before playing with versions, files, etc, could I suggest to Clean the project first? After a very stressful day, this is what sorted my problem.