I have a web site with a single 'app_offline.htm' file. How can i configure IIS to return it with specific status code (say, 209) instead of default one (200)?
An alternative to using the 'app_offline.htm' feature of ASP.Net could be to use the IIS URL Rewrite Module, it has a huge bag of tricks and setting custom response codes is one of them.
If the content of the page is not important, only the response code, then with that module you can configure a rule that will return a blank response with a 209 code to any request as long as the rule is enabled.
That will materialise in your web.config as something like this:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With