在为特定网址提供app_offline.htm时,将http状态503更改为200 [英] Change http status 503 to 200 when serving app_offline.htm for specific URL

查看:122
本文介绍了在为特定网址提供app_offline.htm时,将http状态503更改为200的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ASP.NET服务的app_offline.htm文件返回http状态503.对于大多数情况,这是正确的行为.但是,在请求特定URL(例如 https://www.mywebsite.com/monitor )的情况下,我d希望将返回的http状态更改为200,同时在所有其他情况下仍返回http状态503.这可能吗?

The app_offline.htm file that ASP.NET serves returns the http status 503. This is the correct behavior for most situations. However, in the scenario where a specific URL is requested (e.g. https://www.mywebsite.com/monitor), I'd like to change the returned http status to 200, while still returning http status 503 in all other situations. Is this possible?

我要这样做的原因是,每当我们在网站上进行计划维护时,我们都使用app_offline.htm文件,但我们不希望正常运行时间监视服务(Pingdom.com)在计划的计划期间报告停机时间维护.

The reason why I want to do this is whenever we do scheduled maintenance on our website, we use the app_offline.htm file, but we don't want our uptime monitoring service (Pingdom.com) to report downtime during our scheduled maintenance.

我认为这必须在IIS级别,因为app_offline.htm在请求处理周期的很早就得到了服务.

I assume this would have to be at the IIS level because the app_offline.htm gets served very early on in the request processing cycle.

推荐答案

请注意,只有 App_Offline 可以减少ASP.NET的使用,它与IIS站点无关.所有非ASP.NET请求(如.htm)都将通过普通的IIS管道.

Note that App_Offline is only there to take the ASP.NET part down, it has nothing to do with the IIS site. All non-ASP.NET request -like .htm- will go through the normal IIS pipeline.

话虽这么说, HTTP 503 是无法使用的服务错误. App_Offline.htm 使网站部分脱机,这是正常的,并且更正了当站点脱机时,所有ASP.NET请求都得到 503 响应.

That being said, a HTTP 503 is an unavailable service error. The App_Offline.htm take the site partially offline, it is normal and correct that all ASP.NET request get a 503 response when the site is offline.

使用HttpModule或ASP.NET管道中的任何代码来绕过此方法都不是有效的解决方案.

Bypass this with a HttpModule or whatever code in the ASP.NET pipeline is not a valid solution.

由于在维护过程中已经在IIS根目录中创建/复制了 App_Offline.htm ,所以我建议添加 maintenance.htm 作为默认文档,您的/monitor 文件夹或IIS站点,并在维护期间在其中创建/复制 maintenance.htm 文件:然后,无论ASP.NET站点位于什么位置,默认页面都可以访问是否离线.

Since you'are already creating/copying the App_Offline.htm in your IIS root during maintenance, I'll suggest to add maintenance.htm as a default document for your /monitor folder or your IIS site and create/copy a maintenance.htm file in it during maintenance : then the default page will be reach whatever the ASP.NET site is offline or not.

如果您的探针在未指定任何页面的情况下调用 http://servername/monitor/ uri,它将起作用.

If your probe is calling the http://servername/monitor/ uri without any page specified, it will work.

您只需删除它-就像在维护后删除 App_Offline -一样.

You just have to delete it -like you delete your App_Offline- after the maintenance.

这篇关于在为特定网址提供app_offline.htm时,将http状态503更改为200的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆