Click here to Skip to main content
Licence CPOL
First Posted 21 Jul 2011
Views 6,275
Downloads 0
Bookmarked 13 times

ASP.NET Diagnostic Page to Dump ASP.NET and Environment Configuration

By | 21 Jul 2011 | Article
A handy ASPX page that you can just copy on any website and it dumps the Environment settings and common ASP.NET settings to help diagnose various problems.
Diagnostic_Page_Dump.png

Introduction

Sometimes you need to quickly see if your ASP.NET site is running on the correct server, from the correct code location, using the correct .NET runtime, on a correct OS and hardware environment. Especially if you are running on a shared hosting and you do not have access to the server configuration, dumping Environment variables gives you valuable information about the server processor and you can find out whether the hosting company is putting you on a cheap server. Here’s a handy ASPX page that you can just copy on any website and it dumps the Environment settings and common ASP.NET settings to help diagnose various problems.

ASP.NET_Diagnostic_Page.png

It dumps all the Environment variables. I have only shown a few on the screenshot. Then it dumps some useful Request properties. Then it has the ASP.NET tracing output which gives very useful content.

The code of the page is very simple: 

<%@ Page Language="C#" AutoEventWireup="true" Trace="true" TraceMode="SortByCategory" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>ASP.NET Diagnostic Page</title>
</head>
<body>
  <form id="form1" runat="server">
  
  <h2>Environment Variables</h2>
  <pre>
  <table>  
<%
    var variables = Environment.GetEnvironmentVariables();
    foreach (DictionaryEntry entry in variables)
    {
      Response.Write("<tr><td>");
      Response.Write(entry.Key);
      Response.Write("</td><td>");
      Response.Write(entry.Value);
      Response.Write("</td></tr>");
    }
  %>
  </table>
  </pre>

  <h2>Misc</h2>
  <pre>
  Response.Filter = <%= Request.Filter.ToString() %>
  Request.ApplicationPath = <%= Request.ApplicationPath %>
  Request.PhysicalApplicationPath = <%= Request.PhysicalApplicationPath %>
  Request.PhysicalPath = <%= Request.PhysicalPath %>
  Request.UrlReferrer = <%= Request.UrlReferrer %>
  Request.UserLanguages = <%= string.Join(",", (Request.UserLanguages ?? new string[0])) %>
  </pre>
  
  </form>
</body>
</html>

That’s all in the Dump.aspx. Just drop this page on a website and you are ready to go. 

How to Use this Page

You can use this to test many things:

  • Dump the cookies browser is sending to your website and see if the cookies are correct. Sometimes you get bad cookie injected in browser by some code and it causes your code to fail. Using this page, you can test that.
  • See if server has the right .NET framework installed.
  • Verify if the site is running from the correct webserver by looking at the machine name.
  • Test if load balancer is working. Deploy this page on all your webservers. Then keep refreshing the page. You should see a different machine name being dumped on different page loads.
  • Check what is in Session and see if there's something incorrect stored in session that might be causing your application to fail. See if Session is being created at all or not.
  • Test if you are getting right Request Headers.
  • Set this page as some form's POST page and make a post to this page to see what is getting posted.

These are just some of the ways you can make use of this page to test your webserver, application code, form posts, AJAX calls and so on.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Omar Al Zabir

Architect
BT, UK (ex British Telecom)
United Kingdom United Kingdom

Member

I am: Chief Architect, SaaS Platform, BT (ex British Telecom). Visual C# MVP '05-'07, ASP.NET/IIS MVP '08-'12
I was: Co-founder & CTO, Pageflakes(www.pageflakes.com)
I like: Performance and Scalability Challenges.
My Book: Building a Web 2.0 portal using ASP.NET 3.5. Also on Amazon
My Blog: http://omaralzabir.com
My Specialization: Web 2.0 Rich AJAX Applications, Level 4 SaaS, Performance and Scalability of Web Apps.
My Email: OmarALZabir at gmail dot com
 
Follow Me: twitter.com/omaralzabir
 
My Projects:
Open Source Web 2.0 AJAX Portal
PlantUML Editor - Super fast UML editor
Smart UML - Freehand UML Designer
RSS Aggregator both Outlook and Standalone
Store Front in JSP but ASP.NET style
 
My Articles:
Top 10 caching mistakes
99.99% Available Production Architecture
Build GoogleIG like Ajax Start Page in 7 days
10 ASP.NET Performance and Scalability Secrets
ASP.NET AJAX under the hood secrets
UFrame: UpdatePanel and IFRAME combined
Fast ASP.NET web page loading
Fast Streaming AJAX Proxy
Using COM safely inside "using" block without requiring interop assembly
Implementing Word Like Automation Model
Distributed Command Pattern

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Suggestion5 and small suggestion PinmemberOmari O.8:39 21 Jul '11  
GeneralRe: 5 and small suggestion Pinmemberrohit_k..21:31 17 Apr '12  
GeneralRe: 5 and small suggestion Pinmemberrohit_k..18:25 20 Apr '12  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 21 Jul 2011
Article Copyright 2011 by Omar Al Zabir
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid