User-460007017 posted
Hi HC4u,
It depend on when do you want to display the message? The app_offline.htm is not a page that return message when you stop IIS. It also require user to leave the IIS site online. When you put app_offline under the root folder, it will only redirect
all the request to .aspx to specific folder. It is also not working with static file like html. IIS could not return message when IIS stop as well.
So if you need to let all the site to offline, you could create a URL rewrite global rule instead.
<rule name="return error" stopProcessing="true">
<match url="(.*)" />
<action type="CustomResponse" statusCode="511" subStatusCode="2" statusReason="updating" statusDescription="error message" />
</rule>
You could just input the custom status code and the statsu description attribute is the content that you want to return.
Just remember to put it in applicationhost.config as global rule.
In addition, you could create a rule to redirect/rewrite all the request to specific URL when you want to get all the website offline.
https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
Best Regards,
Yuk Ding