Sunday, August 22, 2010

Website diagnostics page to diagnose your ASP.NET website

Introduction
Whenever you change web.config file or deploy your website on a new environment, you have to try out many relevant features to confirm if the configuration changes or the environment is correct. Sometimes you have to run a smoke test on the website to confirm if the site is running fine. Moreover, if some external database, webservice or network connectivity is down, it takes time to nail down exactly where the problem is. Having a self-diagnostics page on your website like the one you see on your printer can help identify exactly where’s the problem. Here’s a way how you can quickly create a simple self-diagnostics page in a single page without spending too much effort. This diagnostics page tests for common configuration settings like connection string, ASP.NET Membership configurations, SMTP settings, <appSettings> file paths and URLs items and some application specific settings to confirm if the changes are all correct.
Building the self-diagnostics page framework
I have used the UpdatePanel and an AJAX Timer to perform each diagnostics step. Every 500ms is performs an async postback to the page and the page carries out one particular diagnostics step and shows the output. This way even if the whole diagnostics process takes a lot of time to complete, it won’t time out the page. It will perform one step at a time.
Read more: Codeproject