I am building an ASP.NET MVC3 computer support ticketing portal.
There is a maintenance state, where it is best to forbid the users from interacting with EF/Database, to avoid “collisions” I am currently getting.
I have an IMaintenanceDispatcher that has a boolean property IsOnMaintenance set to true by the business logic, whenever a background logic puts the portal in that state.
I need to redirect client requests to a parking page for the time of maintenance.
Where do I place the logic that will check if the IsOnMaintenance is true, and if so, do a redirect to a URL?
You could put it in an
ActionFilterAttributeand apply that attribute to any applicable actions/controllers or globally.Note, your action method parameters needs to contain a variable named
ticketIdfor thefilterContext.ActionParameters.TryGetValueto work.Note: I had assumed that an individual ticket is put into maintenance mode and you were wanting to check for that… but re-reading the question it seems like you want to put the whole area/site on hold. Even with that case, the
ActionFilterAttributeexample still holds… just not as different.