Use custom application status pages
You can customize the application status pages by directly modifying the HTML pages that are located in the AppData folder or by overriding the SitefinityHttpModule methods programatically.
Modify the HTML pages
Sitefinity CMS creates HTML pages under the AppData folder of your application, which are reused during later system startup or upgrade phases. If such pages exist, the system reuses them. If no such pages are present, system creates them using default markup embedded in Sitefinity CMS. In case you want a different design, you can modify these pages.
For more information, see Types of application status pages » Status page location.
Override the SitefinityHttpModule methods
You could implement custom pages during the restart and upgrade phases of Sitefinity CMS by overriding the following SitefinityHttpModule methods:
OnSystemRestarting(HttpContext context, string html = null, string scriptUrl = null)
This method is called on the initial request during system restart. Because the system is not able to handle the request at this time, this method completes the request and sends The system is initializing/restarting... message.OnSystemUpgrading(HttpContext context, string html = null, string scriptUrl = null)
This method is called on the initial request during system upgrade. The request should be completed here, because the system is not able to handle the request at this time, this method completes the request and sends The system is upgrading... message.
To customize the application status pages, perform the following:
- Open your project in Visual Studio.
- In the context menu of SitefinityWebApp, click Add» Class...
This way, you add add a custom Http Module class that derives fromSitefinityHttpModule. - Override the
OnSystemRestartingandOnSystemUpgradingmethods by pasting the following code inside the newly created class:C#using System.Web; using System.Web.Hosting; using Telerik.Sitefinity.Web; namespace SitefinityWebApp { public class CustomSitefinityHttpModule : SitefinityHttpModule { private static readonly string systemRestartingHtml = @" <html> <head> <script src=""https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js""></script> </head> <body> <div align=""center""> <section> <h1>The system is restarting...</h1> <div> <progress></progress> <br/><br/> <object data=""http://www.youtube.com/embed/tpwNv29XbbQ?autoplay=1"" width=""560"" height=""315""></object> </div> <section> </div> <input type=""hidden"" id=""applicationVirtualPath"" value=""{0}"" /> <script type=""text/javascript"">{1}</script> </body> </html>"; private static readonly string systemUpgradingHtml = @" <html> <head> <script src=""https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js""></script> </head> <body> <div align=""center""> <section> <h1>The system is upgrading...</h1> <div> <progress></progress> <br/><br/> <object data=""http://www.youtube.com/embed/CcyWiNAnNiI?autoplay=1"" width=""560"" height=""315""></object> </div> <section> </div> <input type=""hidden"" id=""applicationVirtualPath"" value=""{0}"" /> <script type=""text/javascript"">{1}</script> </body> </html>"; private static readonly string redirectToUrlScript = @" ; (function () { var appVirtualPath = document.getElementById('applicationVirtualPath') ? document.getElementById('applicationVirtualPath').value : ''; var getURLParameter = function (name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, """"])[1].replace(/\+/g, '%20')) || null }; var redirectToReturnUrl = function () { var returnUrl = getURLParameter('ReturnUrl'); window.location = returnUrl ? returnUrl : location.protocol() + '://' + location.host(); }; var getAppStatus = function () { var request = new XMLHttpRequest(); request.open('GET', appVirtualPath + '/appstatus', false); request.send(); if (request.status === 404) { redirectToReturnUrl(); } }; var getAppStatusInterval = function () { setInterval(function () { getAppStatus(); }, 3000); }; getAppStatus(); getAppStatusInterval(); })(); "; protected override void OnSystemRestarting(HttpContext context, string html = null, string scriptUrl = null) { CustomSitefinityHttpModule.DisplayPage(context, CustomSitefinityHttpModule.systemRestartingHtml); } protected override void OnSystemUpgrading(HttpContext context, string html = null, string scriptUrl = null) { CustomSitefinityHttpModule.DisplayPage(context, CustomSitefinityHttpModule.systemUpgradingHtml); } private static void DisplayPage(HttpContext context, string html) { var applicationVirtualPath = HostingEnvironment.ApplicationVirtualPath.TrimEnd('/') ?? string.Empty; context.Response.AddHeader("Content-Type", "text/html; charset=" + context.Response.Charset); context.Response.StatusCode = 200; context.Response.Write(string.Format(html, applicationVirtualPath, CustomSitefinityHttpModule.redirectToUrlScript)); context.ApplicationInstance.CompleteRequest(); } } } - Register your new module in your
web.config.
Perform the following:XML<!-- Find the following: --> <add name="Sitefinity" type="Telerik.Sitefinity.Web.SitefinityHttpModule, Telerik.Sitefinity" /> <!-- Replace with the following: --> <add name="Sitefinity" type="SitefinityWebApp.CustomSitefinityHttpModule, SitefinityWebApp" />