How to get web Server Information using .NET

No.of Views3482
Bookmarked0 times
By  ninethsense   On  06 Sep 2010 11:09:42
Tag : ASP.NET , How to
This articles explains about a tool which can be used to get web server information using WebClient in .NET
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at



This article is about a tool which you can use to get information like encoding, cookie details, web server name, server language, their version numbers, etc.

Image Loading

Are they accurate?

We cannot guarantee as it is possible for the server guys to fake/disable parameters if they wish.

About WebClient

WebClient belongs to System.Net.WebClient. You can find the MSDN page here -

WebClient provides common methods for sending data to and receiving data from a resoruce identified by a URI.This feature is available from .NET Framework version 2.0. I have made use of this feature for building this handy tool.

How to use code

This is the heart code of this tool which gets data from the server and displays the parameters to a textbox.

WebClient wc = new WebClient();
// This line adds a user agent string to header of Web Client.// user agent is optional but some websites/servers use this string// to veryfy whether you are a bot or browser. We use this to act our tool // like a browser.// More info about user agent here -"user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); 

// Below line reads informaion from the server of specified website.// OpenRead() method returns the contents of the file, but since we do not need// it for our tool, I am not reading it to a variable.wc.OpenRead(site); 

// wc.ResponseHeaders contents all the header responses from server.// I am adding those information to a StringBuilder variable with some formatting.// wc.ResponseHeaders.Count returns number of keys/values available. // Count varries from website to webstiefor (int i = 0; i < wc.ResponseHeaders.Count; i++)
     sb.Append((i + 1).ToString() + ". [" + wc.ResponseHeaders.AllKeys[i] + "] => " 
     + wc.ResponseHeaders[i] + Environment.NewLine + Environment.NewLine);

// Fiinally, the formatted string is passed to the multi-line textboxtextBox1.Text = sb.ToString();

 WebClient.ResponseHeaders is the property which brings our necessary parameters from the server.

Who can benifit from this tool?

Well, technology enthusiasts, I would say. If somebody is interested to know which website runs on which server/language, then this tool is for them.

Some of my observations with this tool here:.

  • - gws (Google Web Server)
  • - IIS6, ASP.NET 3.5
  • - IIS 7.5/ASP.NET 4.0
  •  msdn - IIS 7.5/ASP.NET 2.0
  • - Apache 1.3/PHP 5.2
  • - Apache 2.3
  • - Apache 2.3/Python 2.5
  •  gmail - GSE (Google Search Extension)
  • - Oracle Application Server
  • - Sun Java System Web Server
  • - Apache

Sample Project Source 

Download source files -25 kb

Download demo -4 kb

That's all enjoy happy coding.

Sign Up to vote for this article
About Author
Member Type-Junior
Location-Not Provided
Joined date-21 Jul 2009
Home Page-
Blog Page-
Other popularSectionarticles
There is no comments for this articles.
Leave a Reply
Display Name:
(not display in page for the security purphase)
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top