what is the use of WebHeaderCollection while downloading a web site,explanation
Headers = new WebHeaderCollection();
RequestUri = uri;
Headers["Host"] = uri.Host;
Headers["User-Agent"] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)";
how will this command work........
Master BillaPosted Oct 16, 2009, 2:38 AM
here my code to get all headers when your page is downloading,
private void GetHeader()
{
Uri uri = new Uri(txtUrl.Text.Trim());
WebClient myClient = new WebClient();
// Open the page and get the response as a stream
Stream response = myClient.OpenRead("http://www.google.com");
WebHeaderCollection headers = myClient.ResponseHeaders;
Response.Write("Response headers:
");
for (int i = 0; i < headers.Count; i++)
{
Response.Write(headers.GetKey(i) + " : " + headers.Get(i) + "
");
}
StreamReader sr = new StreamReader(response);
// read the response into a string and show the result.
string s = sr.ReadToEnd();
Response.Write(s);
sr.Close();
response.Close();
}