【发布时间】:2012-12-25 04:32:46
【问题描述】:
我正在尝试为网站创建一个Temporarily Down for Site Maintenance 保留页面。该网站是asp.net 4 webform 网站。
我创建了一个offline.aspx 页面,当我关闭网站时,我会将所有流量重定向到该页面。
在此页面上,我想发送 503 响应代码并指定网站恢复在线的日期 - 使用来自google here的信息
我希望它可以在我的PageLoad 中做一些事情,比如:
Response.ClearHeaders();
Response.ClearContent();
Response.StatusCode = 503;
Response.StatusDescription = "HTTP/1.1 503 Service Temporarily Unavailable";
Response.Flush();
throw new HttpException(503, "Temporarily Down For Maintenance.");
这给了我正确的状态,但页面上出现以下错误:
XML Parsing Error: not well-formed
Location: http://xyz/offline.aspx
Line Number 3, Column 2:</pre></table></table></table></table></table></font></font></font></font></font></i></i></i></i></i></b></b></b></b></b></u></u></u></u></u><p> </p><hr>
我想我错过了一些简单的东西,我做错了什么?
另外,我会使用Response.AddHeader 在503 之后添加重试标头吗?
编辑:我在删除东西时过于热心了。清理所有删除和清除内容可以使以下工作:
Response.StatusCode = 503;
Response.StatusDescription = "HTTP/1.1 503 Service Temporarily Unavailable";
Response.AddHeader("Retry-After", "Sat, 12 Jan 2013 23:00:00 GMT");
Response.Flush();
【问题讨论】:
标签: c# asp.net webforms httpresponse http-status-code-503