The processing of app_offline.htm is hard-coded in the ASP.NET pipeline and cannot be changed: see CheckApplicationEnabled() in HttpRuntime.cs , where it throws a very non-configurable 404 error if the application is considered offline.
However, creating your own HTTP module to do something similar is, of course, trivial - the OnBeginRequest handler may look like this in this case (the implementation for HttpHandler is shown, but the idea is exactly the same in HttpModule):
Public Sub ProcessRequest(ByVal ctx As System.Web.HttpContext) Implements IHttpHandler.ProcessRequest If IO.File.Exists(ctx.Server.MapPath("/app_unavailable.htm")) Then ctx.Response.Status = "503 Unavailable (in Maintenance Mode)" ctx.Response.Write(String.Format("<html><h1>{0}</h1></html>", ctx.Response.Status)) ctx.Response.End() End If End Sub
This is just the starting point, of course: by making the returned HTML a little friendlier, you can also display a good “we'll be back” page for your users.
source share