Down For Service Website

I have a public website (associated with the Bank) that should be updated by PROD in the coming weeks. I need to display the “Down for Service” page during the shutdown window. Since the bank provided me with certain requirements for the page, which should be designed in the same way as the website itself, I don’t think the app_offline.htm solution will work for me, because I can’t access my stylesheets and images, because IIS redirects all requests to this page.

I was wondering what would be the best solution design so that I can use styles and images on my website on my service page? I was told that a good way to do this is to create a new website, enable the style and images and expand it as a separate website in IIS <and then during the disconnect window, I will switch the IP address binding in IIS to point to my website service. Upon completion of maintenance, I will switch it back to the main site. Is this a good way to do this?

UPDATE:

I implemented the following, and it seems to work very well. When I drop the Outage.htm or Maintenance.htm file into my web root folder, it will redirect accordingly. Disconnection and scheduled maintenance have different styles and content, so I had to create 2 pages. In addition, when in the shutdown or maintenance mode and the request comes from localhost, do not redirect to allow testing the website after performing the service, 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);
    }
}
+4
source share
1 answer

I implemented the following, and it seems to work very well. When I drop the Outage.htm or Maintenance.htm file into my web root folder, it will redirect accordingly. Disconnection and scheduled maintenance have different styles and content, so I had to create 2 pages. In addition, when in the shutdown or maintenance mode and the request comes from localhost, do not redirect to allow testing the website after performing the service, 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);
    }
}
+3
source

Source: https://habr.com/ru/post/1605660/


All Articles