Updated on Kisan Patel
Problems:
How to take an ASP.NET MVC web site “Down for maintenance”?
Implement “Down for maintenance” page.
Web site Maintenance Page ASP.NET MVC.
How to put your site into “maintenance mode”?
Solution
public class MvcApplication : System.Web.HttpApplication { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new CheckForDownPage()); } //the rest of your global asax //.... } public class CheckForDownPage : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { var path = System.Web.Hosting.HostingEnvironment.MapPath("~/Down.htm"); if (System.IO.File.Exists(path) && IpAddress != "1.2.3.4") { filterContext.HttpContext.Response.Clear(); filterContext.HttpContext.Response.Redirect("~/Down.htm"); return; } base.OnActionExecuting(filterContext); } }