I'm trying to create a Temporarily Down for Site Maintenance
holding page for a website. The website is an asp.net 4 webform
site.
I've created a offline.aspx
page that I will redirect all traffic to when I take the site down.
On this page, I would like to send a 503 response code and specify the date that the site will be back online - using the information from google here
I was hoping that it I could do something in my PageLoad
like:
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.");
which gives me the correct status but the following error on the page:
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>
I think I'm missing something simple, what am I doing wrong?
Also, would I use Response.AddHeader
to add a retry header after the 503
?
Edit: I got way overzealous in my removal off stuff. Cleaning up all the removals and clearing of content gets the following to work:
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();