Examine the headers : HttpWebRequest « Network « C# / CSharp Tutorial






using System; 
using System.Net; 
 
class MainClass {  
  public static void Main() { 
 
    HttpWebRequest req = (HttpWebRequest) WebRequest.Create("http://www.java2s.com"); 
 
    HttpWebResponse resp = (HttpWebResponse) req.GetResponse(); 
 
    string[] names = resp.Headers.AllKeys; 
 
    Console.WriteLine("{0,-20}{1}\n", "Name", "Value"); 
    foreach(string n in names) 
      Console.WriteLine("{0,-20}{1}", n, resp.Headers[n]); 
 
    resp.Close(); 
  } 
}
Name                Value

Connection          close
Accept-Ranges       bytes
Content-Length      341387
Content-Type        text/html
Date                Sun, 25 Mar 2007 21:06:43 GMT
ETag                "14904bc-5358b-bce5400"
Last-Modified       Tue, 20 Feb 2007 15:25:04 GMT
Server              Apache/2.0.54 (Fedora)








33.22.HttpWebRequest
33.22.1.Examine the headers
33.22.2.Access the Internet