Dec 27
Reading the contents of a web page is easy in C# with the System.Net.WebClient class:
using System.Net; using System.Windows.Forms; string url = "http://www.devtopics.com"; string result = null; try { WebClient client = new WebClient(); result = client.DownloadString( url ); } catch (Exception ex) { // handle error MessageBox.Show( ex.Message ); }
The web page is read into the ‘result’ string. Note the URL you pass to the DownloadString method must have the http:// prefix, otherwise it will throw a WebException.
A more complicated but also more flexible solution is to use the System.Net.HttpWebRequest class, which enables you to interact directly with servers using HTTP:
using System.Net; using System.IO; using System.Windows.Forms; string result = null; string url = "http://www.devtopics.com"; WebResponse response = null; StreamReader reader = null; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create( url ); request.Method = "GET"; response = request.GetResponse(); reader = new StreamReader( response.GetResponseStream(), Encoding.UTF8 ); result = reader.ReadToEnd(); } catch (Exception ex) { // handle error MessageBox.Show( ex.Message ); } finally { if (reader != null) reader.Close(); if (response != null) response.Close(); }
Copyright © 2007-8 Tiwebb Ltd. All rights reserved. This material may not be published, broadcast, rewritten or redistributed without explicit permission from Tiwebb Ltd.

You can also add headers in both WebClient and HttpWebRequest. Take a look at http://msdn2.microsoft.com/en-us/library/system.net.webclient.aspx and http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.headers(VS.85).aspx
Sorry