gpt4 book ai didi

asp.net - app_offline.htm 在生产设备上抛出 HTTP 500 错误

转载 作者:行者123 更新时间:2023-12-03 22:22:29 25 4
gpt4 key购买 nike

我创建了一个 app_offline.htm 在 IIS7/Win2008 64 位上运行的 ASP.NET MVC2 应用程序的文件,并确保它超过 512 字节(现在是 2KB)。在我运行 Visual Studio 2010 的开发箱上,它就像一个魅力,但是当我把它放在生产箱上时,我得到的只是一般的 HTTP 500 错误,说“页面无法显示,因为发生了内部服务器错误。”

特别奇怪的是,我没有在应用程序事件日志中记录任何内容,ELMAH 也没有发现任何内容。我已经禁用了自定义错误,为文件设置了 FormsAuthentication 位置异常,确保我没有引用任何其他文件(图像等),但没有任何解决方法。

我已经阅读了 SO 上的每篇文章,并在谷歌上搜索了几个小时,但无法弄清楚这一点。任何想法可能有什么问题?我在这里拔头发...

最佳答案

更新:
你的 web.config 中有这个吗?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<httpRuntime waitChangeNotification="300" maxWaitChangeNotification="300"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>

But there’s one more catch.

ASP.NET will unload the application as soon as the web.config is changed, but it won’t actually reload it and apply the “waitChange…” settings until a request is made. So you could still drop the app_offline.htm and web.config in, and if the first requst occurs while a dll is only half copied, the exception will occur. To add insult to injury, the exception will persist until you replace the temporary web.config or the total duration of your “waitChange…” time expires!

To get around this final hurdle, you’d need to make a request to the application after uploading the temporary web.config, but before you start deploying the application files. The complete process is as follows:

  1. Add app_offline.htm
  2. Replace application’s web.config with a temporary web.config (as above)
  3. Request any ASP.NET resource on the site so the new waitChangeNotification gets “applied”*
  4. Make any file system changes necessary (deploy bin dlls, other site files)
  5. Replace temporary web.config with the original application web.config
  6. Delete app_offline.htm

*You may dispute what happens in step 2-3, since ASP.NET shuts down the application after step 1. Indeed, it does not appear from my event viewer that the web.config change is registered or “applied” as a result of either step 2 or 3, but nevertheless the updated waitChangeNotification settings do get applied after step 3.



More app_offline.htm woes

App_offline.htm gotchas with ASP.NET MVC

关于asp.net - app_offline.htm 在生产设备上抛出 HTTP 500 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4928480/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com