app_offline网站返回"服务不可用".

ama*_*eur 20 iis-7 app-offline.htm

我正在遵循Scott gu的伎俩,在我的应用程序的路径上放置一个App_Offline.htm页面使其脱机 - http://weblogs.asp.net/scottgu/archive/2006/04/09/442332.aspx

但它似乎并没有在我的某个网站上运行.我将文件放在我的一个站点的IIS7中,所有流量都被重定向到它.

但是在其他站点,同一服务器等中,我得到一个包含"服务不可用"的页面.

不知道我哪里错了 - 任何想法?

dem*_*key 18

我设法通过在web.config中放入以下代码来解决它:

<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />

        <defaultDocument>
            <files>
                <clear />
                <add value="index.html" />
                <add value="app_offline.htm" />
            </files>
        </defaultDocument>

        <httpErrors errorMode="Custom" existingResponse="Replace">
            <clear />
            <error statusCode="503" path="App_Offline.htm" responseMode="File" />
        </httpErrors>
    </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

通过汇总Scott Gu,npiaseck @ IIS ForumKurt Schindler的一些信息找到了这个修复程序.

  • 对我而言,关键的一点似乎只是我错过了503响应代码的httpErrors中的行.其他变化似乎没有必要. (4认同)
  • 没有什么比谷歌搜索一个问题并找到一个链接到你六年前发布的解决方案的 StackOverflow 答案更像的了,因为你显然以前遇到过这个问题,但忘记了你遇到过它以及你是如何解决它的;) (3认同)

JGi*_*tin 10

这是我的解决方案 - 请注意503 ...

    <httpErrors existingResponse="Replace" errorMode="Custom">
  <remove statusCode="404" subStatusCode='-1' />
  <remove statusCode="400" subStatusCode='-1' />
  <remove statusCode="500" subStatusCode='-1' />
  <remove statusCode="503" subStatusCode='-1' />
  <error statusCode="404" path="404.html" prefixLanguageFilePath="" responseMode="File" />
  <error statusCode="400" path="404.html" prefixLanguageFilePath="" responseMode="File" />
  <error statusCode="500" path="500.html" prefixLanguageFilePath="" responseMode="File" />
  <error statusCode="503" path="app_offline.htm" responseMode="File" />

</httpErrors>
Run Code Online (Sandbox Code Playgroud)


Hen*_*y C 2

我最近在一个 MVC 站点上遇到了这个问题,当我想要使用 app_offline.htm 文件时,我通过用一个干净的、最小的配置替换原来的 web.config 来解决这个问题。

<?xml version="1.0"?>
<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
    </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

如果我有更多时间,我会仔细检查并在 web.config 中找到改变行为的确切内容,但这值得一试。