I have a public facing website (Banking related) which is due for a PROD update in the next coming weeks. I need to display a "Down for maintenance" page during the outage window.Because the bank has provided me with specific requirements for the page, which needs to be styled exactly the same as the website itself, I dont think the app_offline.htm solution will work for me as I wont be able to access my style sheets and images, because IIS redirect all requests to this page.
I was wondering, what would be the best solution design so I can make use of the styling and images in my website on my maintenance page? I was told that a good way to do this is to create a new website, include the styling and images, and deploy that as a seperate website in IIS< and then during the outage window I switch the IP address binding in IIS to point to my maintenance site. Once maintenance is complete, I switch it back to point to the main website. Is this a good way to go about it?
UPDATE:
I implemented the following, and it seems to work pretty well. When I drop the Outage.htm or Maintenance.htm file into my web root folder, it will redirect accordingly. Outage and scheduled maintenance has different styling and content so I had to create 2 pages. Also, when in outage or maintenance mode, and request is coming from localhost, then dont redirect, to allow for testing website after doing maintenance while blocking external requests.
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new CheckForDownPage());
}
}
public sealed class CheckForDownPage : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
string ipAddress = HttpContext.Current.Request.UserHostAddress;
var outagePage = System.Web.Hosting.HostingEnvironment.MapPath("~/Outage.htm");
var maintenancePage = System.Web.Hosting.HostingEnvironment.MapPath("~/Maintenance.htm");
var isOutage = System.IO.File.Exists(outagePage);
var isMaintenance = System.IO.File.Exists(maintenancePage);
if ( (isOutage || isMaintenance) && ipAddress != "::1")
{
filterContext.HttpContext.Response.Clear();
filterContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
filterContext.HttpContext.Response.StatusDescription = "Service Unavailable.";
filterContext.HttpContext.Response.WriteFile(isOutage ? outagePage : maintenancePage);
filterContext.HttpContext.Response.End();
return;
}
base.OnActionExecuting(filterContext);
}
}
Maintenance times can vary greatly. Sometimes a site might be down for only a few minutes. Other times it could be an hour or two, or even longer. Let your visitors know what time you expect to be back up and running.
If your site is stuck in maintenance mode, to get it out of maintenance, you will need to locate the . maintenance file and simply delete it.
If your website is hosted on a shared server by your host, whenever there is a huge surge either to your site, your host might suspend or take your site off to protect other sites. Similarly, if other sites on the server face heavy traffic, due to a bad neighbor effect, it could affect your site's availability as well.
Communication during an outage should: Inform the customer: Let them know what is happening and what that means for them. Build their confidence: Let them know the situation is being taken seriously and actively worked on so they can safely do other work in the meantime.
I implemented the following, and it seems to work pretty well. When I drop the Outage.htm or Maintenance.htm file into my web root folder, it will redirect accordingly. Outage and scheduled maintenance has different styling and content so I had to create 2 pages. Also, when in outage or maintenance mode, and request is coming from localhost, then dont redirect, to allow for testing website after doing maintenance while blocking external requests.
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new CheckForDownPage());
}
}
public sealed class CheckForDownPage : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
string ipAddress = HttpContext.Current.Request.UserHostAddress;
var outagePage = System.Web.Hosting.HostingEnvironment.MapPath("~/Outage.htm");
var maintenancePage = System.Web.Hosting.HostingEnvironment.MapPath("~/Maintenance.htm");
var isOutage = System.IO.File.Exists(outagePage);
var isMaintenance = System.IO.File.Exists(maintenancePage);
if ( (isOutage || isMaintenance) && ipAddress != "::1")
{
filterContext.HttpContext.Response.Clear();
filterContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
filterContext.HttpContext.Response.StatusDescription = "Service Unavailable.";
filterContext.HttpContext.Response.WriteFile(isOutage ? outagePage : maintenancePage);
filterContext.HttpContext.Response.End();
return;
}
base.OnActionExecuting(filterContext);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With