我有一个带有单个“app_offline.htm”文件的网站。我如何配置 IIS 以使用特定状态代码(例如 209)而不是默认状态代码(200)返回它?
使用 ASP.Net 的“app_offline.htm”功能的替代方法是使用IIS URL 重写模块 http://www.iis.net/downloads/microsoft/url-rewrite, 它有一个一大袋技巧 http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference设置自定义响应代码就是其中之一。
如果页面的内容不重要,只有响应代码,那么使用该模块,您可以配置一个规则,该规则将返回带有 209 代码的空白响应any只要规则启用就可以请求。
这将在您的 web.config 中具体化,如下所示:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="app_offline" stopProcessing="true">
<match url=".*" />
<action type="CustomResponse" statusCode="209" statusReason="System unavailable" statusDescription="The site is currently down for maintenance, or something." />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)