Implement custom "System is restarting..." message in Sitefinity

Implement custom "System is restarting..." message in Sitefinity

Posted on August 16, 2014 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

Until now, the message when the application pool is recycled was unextendable, but since our latest internal build (Sitefinity 7.1.5205), this could be easily achieved as our dev team exposed two methods in SitefinityHttpModule:

/// <summary>
        /// Called on begin request during system restarting. The request should be completed here, because the system will not be able to handle the request at this time.
        /// By default sends 'The system is restarting...' message and completes the request.
        /// Can be overridden to implement different behavior.
        /// </summary>
        /// <param name="context">The HTTP context.</param>
        protected virtual void OnSystemRestarting(HttpContext context);
 
        /// <summary>
        /// Sends a response message to the clients with the specified body html and delayed redirect. Completes the request.
        /// </summary>
        /// <param name="context">The HTTP context.</param>
        /// <param name="bodyHtml">The body HTML.</param>
        /// <param name="timeout">The timeout in milliseconds before redirect. By default it is 3000.</param>
        /// <param name="redirctUrl">The redirect URL. Optional, If it is not specified </param>
        public static void SendDelayedRedirect(HttpContext context, string bodyHtml, int timeout = 3000, string redirectUrl = null);

The steps necessary to change the message are as follows:

  1. Create custom SitefinityHttpModule:
  2. namespace SitefinityWebApp.Tests
    {
        /// <summary>
        /// Custom Sitefinity HTTP module - customize the default "The system is restarting..." message
        /// </summary>
        public class CustomSitefinityHttpModule : SitefinityHttpModule
        {
            /// <summary>
            /// Called on begin request during system restarting. The request should be completed here, because the system will not be able to handle the request at this time.
            /// By default sends 'The system is restarting...' message and completes the request.
            /// Can be overridden to implement different behavior.
            /// </summary>
            /// <param name="context">The HTTP context.</param>
            protected override void OnSystemRestarting(HttpContext context)
            {
                SitefinityHttpModule.SendDelayedRedirect(context, "<h2>Custom restarting message</h2><p>Please wait a few seconds. You will be redirected automatically.</p>");
            }
        }
    }

  3. Register the module in the web.config replacing the default one:
  4. <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
          <add name="Sitefinity" type="SitefinityWebApp.Tests.CustomSitefinityHttpModule, SitefinityWebApp" />
          ...

After recycling the application pool the change should take effect.

Vassil Vassilev

View all posts from Vassil Vassilev on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation