method to create a common "maintenance mode" page for an application
Application Type

Hello everyone, I'm looking for any ideas on the easiest/most maintainable way to put an application into "maintenance mode" where users will be redirected to a screen explaining that we are in a scheduled downtime window.  Various back-end systems need to go offline, so no application pages should request or send data during this window.  We should also be able to trigger this status on the fly if those systems go down.  The application in question has four modules (for four types of users), with a shared API module and a common theme module where the error page currently lives, and where the maintenance page is being created.    

Our first thought was to include a web block in the layout that checks a MaintenanceMode site property and throws a User Exception, which would be caught by the OnException action and redirect to the Maintenance page.  However, it seems the exception handler in the layout module is not respected by the block - the exception is instead caught by the AllExceptions handler in the module that uses the layout.

Our current working approach is to check for MaintenanceMode in the block, set a client variable if true, check that client variable in the page module's exception handler and redirect if true.  This is working, but it will require maintaining that exception handler in four separate modules.  (Those modules need to stay separate because there is no SEO URL management in Reactive Web and they need distinct application names.)

Does anyone have a better idea for how to handle this scenario, ideally in a single module?  Is it true that the layout module's OnException handler is not used for web blocks that live in that module, or am I missing something to make that work?

Rank: #231

Hi Douglas,

You can use the OnApplicationReady Event and check whether a Site Propertie is activating maintenance mode or not. If in maintenance mode, activate the Exception.

You can leave that ServerAction public in one of the modules, and use it in all.

I didn't get to test it, but I hope it helps to come up with a solution to your problem



Rank: #2840

Thanks for the suggestion, Eduardo.  I forgot to mention that my original approach was to use OnApplicationReady, although I was using it in the application module, and I had trouble getting a "clean" error.  Throwing an exception in there (whether in the application module or the theme module) seems to cause an actual error not handled by my exception handler.  Maybe I will dig back in there and try to figure out why that is happening - no useful error info is returned, so I'm not sure what's happening.

Rank: #2840

In case anyone is looking for a similar solution, here's where we ended up:

The requirement was to have any application user redirected to a maintenance page without running any data queries (since the point of maintenance mode is that the APIs will be down).  

We tried setting a site property in the shared module where the layout lives, checking that property in the OnInitialize of the layout, throwing an exception if we're in maintenance mode, and redirecting to the maintenance page in the exception handler.  This did not work, because the layout OnInit fires after the page OnInit (allowing page content to render and data queries to fire).  Additionally, if the layout throws the exception is it not handled in the layout module, it is caught by the AllExceptions handler in the consumer module. 

We also tried to leverage the Disable feature and check the application status on the exception, but we can't even do a basic queries to find out if the application is disabled inside the application.  (We tried calling an external module that is not disabled but no luck.)

In the end, every page has to check the site property and throw an exception which is caught in that module and redirects to the maintenance page.  This isn't great since every page needs to do a query (triggering warnings for every page about using OnInit) and every module needs its own version of the maintenance exception.  What we're missing is any one of the following:

  • The ability to check if the site is disabled inside the exception handler
  • The ability to handle an exception in a layout
  • The ability to share an exception handler across modules
  • An OnApplicationInitalize action that mirrors OnApplicationReady but fires before any pages are rendered

If anyone has any more clever ideas, please post them up!  The "every page checks OnInit" got us through this time, but we have the same requirement for applications with dozens of pages and I am not looking forward to implementing this hack dozens of times.