![]() |
Development Lifecycle »
Design and Architecture »
General
Advanced
License: The Code Project Open License (CPOL)
Application Block - ASP.NET Website MaintenanceBy Anton Pious AlfredASP.NET Website would eventually be deployed on the production server. As the application grows so too the number of web pages. Invariably bugs or crashes occur. After deployment there should be ways to gracefully maintain this website. |
C# 2.0, Windows, .NET 2.0, ASP.NET, WebForms, VS2005, Architect, Dev
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
ASP.NET Website would eventually be deployed on the production server. The deployment has been fine tuned to deploy a single page with single page assembly which has already been incorporated since VS 2005. As the application grows so too the number of web pages. Invariably bugs or crashes occur. After deployment there should be ways to gracefully maintain this website.
While there are other crude ways to maintain an ASP.NET website I felt this needs to be more structured. Considering that ASP.NET website can span serveral modules with hundreds of pages the level of control regarding maintainance should be configurable. Wouldn't it be better if we are able to have control even to the page level?
This article addresses this issue and is primarily meant for architects, technical leads and configuration managers who care for graceful maintenance of the Web application.
This article uses HttpModule to perform this task along with custom web.config configuration settings.
This has to be used only on Live (Production) or Quality Assurance (Testing) Environment and never on a Development Environment. Can be easily plugged into an existing application by copying the assemblies Comat.WebSiteWatcher.Business.dll and Comat.WebSiteWatcher.Config.dll present in attached binary to the bin folder of the web application and make configurable changes to the web.config file.
This is a HttpModule which is loaded to the HttpModule collection of HttpApplication as depicted in the figure above. This needs to be loaded before redirecting modules like FormsAuthentication etc. We use a HttpModule to prevent unwanted page request processing.
If no redirecting modules present. Add the Module as follows.
<httpModules> <add type="Comat.WebSiteWatcher.Business.WebSiteWatcherModule, Comat.WebSiteWatcher.Business" name="WebsiteWatcher" /> </httpModules>
If redirecting modules like FormsAuthentication is used you need to do a work around. I wish the ASP.NET team can come up with an add module at a particular position than at the end.
<httpModules> <remove name="FormsAuthentication" /> <remove name="UrlAuthorization" /> <add type="Comat.WebSiteWatcher.Business.WebSiteWatcherModule, Comat.WebSiteWatcher.Business" name="WebsiteWatcher" /> <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" /> <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" /> </httpModules>Configuration Settings
Now that the module is loaded we need to provide the configuration settings for it in the web.config file.
<comat.webSiteWatcher isUsed="true"> <webSite isBlocked="false" redirectUrl="~/Maintenance/WebsiteDown.aspx"> <blockFolders redirectUrl="~/Maintenance/ModuleDown.aspx"> <!-- block all folders which have this folder combination --> <blockFolder>/BlockedFolder/SubFolder/</blockFolder> <!-- block only this particular folder --> <blockFolder>http://localhost/Security2005/BillManager/</blockFolder> </blockFolders> <blockPages redirectUrl="~/Maintenance/PageDown.aspx"> <!-- block all pages in any folder with name Customer.aspx --> <blockPage>Customer.aspx</blockPage> <!-- block only this particular page --> <blockPage>http://localhost/Security2005/Default.aspx</blockPage> </blockPages> </webSite> </comat.webSiteWatcher>
The settings are self explanatory. One has control over whether.
Customer.aspx would block all pages in all folders with Customer.aspx.Tilde ~ paths are not supported. If you want absolute path specify the full path like http://localhost/Security2005/Default.aspx . The same holds for the folder. High level switches are given for the WebSite so that you can quickly turn it on in case of a major crash or opt not to use the HttpMododule when not in maintenance mode.
Now that we have specified these settings we need to be able to read it. To do this we create our own custom <configSections> node. We need to add this to the top of the <configuration> settings in web.config file.
<configSections> <section name="comat.webSiteWatcher" type="Comat.WebSiteWatcher.Config.ModuleConfig,Comat.WebSiteWatcher.Config" /> </configSections>Maintenance Pages
The redirectUrl attribute points to pages which display a custom maintenance message like Website, Module or Page is down for maintenance. This needs to be placed in a separate folder and security restriction removed so requests can be redirected to these pages. In this example we use forms authentication and we override these settings by having a web.config in this folder with the following settings.
<system.web> <authorization> <!-- Allow all users --> <allow users="*"/> </authorization> </system.web>
<location> node in web.config can prevent access to a folder without any configuration setting for user specific messages. 13 Aug 2007 : Initial Document.
| You must Sign In to use this message board. | ||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 13 Aug 2007 Editor: |
Copyright 2007 by Anton Pious Alfred Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |