Show “offline” page in MVC3 while updating database?

I have an MVC3 website backed by a SQL server db. The db gets "refreshed" every night which can take around 30 mins.

During this time, I could take the app offline with an app_offline.htm file (and all of the issues that can cause).

The db refresh is controlled from a windows service, since part of this is to import text files from different sources.

I am wondering if there is a cleaner and nicer way to amend the site so that it shows a friendly "Database updating" type page, without taking the site offline?

Answers


A simple way is to add a key the appSettings of your web.config, something like:

<add key="MaintenanceMode" value="true" />

Then you can use the Application_BeginRequest event in the global.asax file and check for the value of the key and redirect to a maintenance page.


I solved this by creating a DatabaseDependant:ActionResultFilterAttribute and applying it to all Action methods that require the DB (or the part of it that gets updated). Applied it to some controllers as well where appropriate.

The filter simply checks a value (used the registry as opposed to app.config as allowed more shared access that the sites app.config) and either redirects or calls the base.


Need Your Help

Propertylist in array passed with segue

ios xcode swift

So I am trying to create a app that is more or less a reference with static data and using a plist to store the data

Sum the total time periods over a given day in MySQL

php mysql sql laravel laravel-4

I need a MySQL query for the following. I have a table of time periods as such below:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.