ASP.Net System Info
Posted: 21/03/2005 13:03:58
Author: Andy Pilgrim
 ASP.Net 1.x Compatible (?)
Introduction
A few days ago, whilst playing with ASP.Net 2.0 (Beta), I began wondering about how one would programmatically check which version of the framework they are dealing with. This lead me to the System.Environment class. This class contains a huge wealth of information about the machine in addition to which version of the framework it is running on. This reminded me of the PHP function phpinfo() which produces a nicely formated output of information about the PHP installation. See a sample (nothing special just the first that came up in a Google Search). Whilst a lot of the information in phpinfo corresponds to the individual PHP modules, much of the information would be useful on any platform. So I set about building a slimmed down version for ASP.Net
What to Include, and How!
Obiously, the most important feature I wanted to include was the version of ASP.Net currently running. This wasn't to hard, just use ToString() on the version returned by the System.Environment class. Also from this class I was able to grab the Operating System version and the time since last reboot!
The class in question also provides access to the system's environment variables which are easily taken and bound to a datagrid. Digging a bit deeper, its not that difficult to get ASP.Net to spit out the request headers and the infamous server variables nicely formated in a datagrid.
None of this being particluarly demanding, I threw it all together on screen. The only slightly tricky part was a bit of complicated math to format the uptime correctly. Putting the number of ticks (in milliseconds) in to a datetime format just to nicen the output seemed overkill, so i plumped for the old fashioned way:
Dim Hours,Days As Integer
Days = Environment.TickCount \ (1000*60*60*24)
Hours = (Environment.TickCount - _
Hours*(1000*60*60*24)) \ (1000*60*60)
uptime.InnerHtml = Days & "days, " & Hours & "hours"
Demo and Source Code
I have decided not to make a demo of the code available - partly because I expect that knowledge of some of the information this code provides might give hackers a helping hand. Instead, you may download the code (link below) and try it for yourself!
WARNING: I would advise against putting this code on publically accessible servers!
Source Code
http://download.semichaos.com/aspnetinfo.zip
Comments, Suggestions
I am looking to expand this tool to include more information. If you can think of any other useful output that I could write in please contact me.
|