3

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>&nbsp;</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();
spajce
  • 7,044
  • 5
  • 29
  • 44
OpenR
  • 186
  • 1
  • 11

1 Answers1

0

I believe this is actually a function of the webserver or the ASP.Net DLL. In the event that some data has already been streamed to the client the error message would not be displayed properly were it not for these random closing tags.

Spencer Ruport
  • 34,865
  • 12
  • 85
  • 147
  • Thanks. It wasn't the answer but you keyed me in to the fact that I was probably removing something needed to finish out displaying the data that had already started. This led me to the answer I posted above. – OpenR Jan 10 '13 at 18:16