Using Server.Transfer
to show a page that informs the user that the web site is at maintenance mode.
At global.asax:
void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.IsLocal)
return;
if (ConfigurationManager.AppSettings["MaintenanceMode"] == "true")
{
if (Request.AcceptTypes != null && Request.AcceptTypes[0] == "text/html")
Server.Transfer("~/UserMessage.aspx?Maintenance");
}
}
Works well except when looking at the page source code I see that the CSS path has been updated but images' paths are not.
Any suggestions?
I would use
app_offline.htm
in the application root or at the very leastResponse.Redirect
if I were you,Server.Transfer
does not change the HTTP address, so you have to be careful redirecting all assets to the underlying page or make all addresses absolute