How to get website header information in C#
With the following function you can easily retrieve a list of website headers in C#. The function needs only the url of a webpage to collect the data. If the function is successfully executed, you’ll get a Dictionary, typed as <string, string>, as return value. This Dictionary<string, string> contains all the headers of the webpage, whose url you passed by at function call time.
//Don’t forget to set the using-directive ;)
using System.Net;
//…
public Dictionary getHeaders(string url)
{
//Dictionary which shall contain the header information
Dictionary header = new Dictionary();
//Create webrequest
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
//Create response object
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//Read all headers from the response
foreach (string headerItem in response.Headers)
{
//Add header to the dictionary
[…]
Today I’ll show you how to send easily emails in C#. All that is required, comes with the System.Net.Mail namespace.
I’m just stumbled once again on a beautiful website that I want to share with you.
I know, why I love my Android smartphone. It is open, flexible and the opportunities to use it seem to be endless. In times companies don’t let me choose, what software I can use to I transfer my music onto the device (Apple – iTunes), I, as an Android user, can ask myself the question: “Should I install the new Cyanogen Mod or straigt way a full-value Linux distribution on my device today? “.
It can be used parallel to Android as it is launched from […]