WebClient.ResponseHeaders : WebClient « System.Net « C# / C Sharp by API






WebClient.ResponseHeaders

 

using System;
using System.IO;
using System.Net;

public class TryURL {
  public static void Main(String [] args) {
    WebClient client = new WebClient();
    client.BaseAddress = "http://www.java2s.com";
    client.DownloadFile("www.java2s.com", "index.htm");
    StreamReader input =new StreamReader(client.OpenRead("index.htm"));
    Console.WriteLine(input.ReadToEnd());
    Console.WriteLine
      ("Request header count: {0}", client.Headers.Count);
    WebHeaderCollection header = client.ResponseHeaders;
    Console.WriteLine
      ("Response header count: {0}", header.Count);
    for (int i = 0; i < header.Count; i++)
      Console.WriteLine("   {0} : {1}", 
                          header.GetKey(i), header[i]);
    input.Close();
  }
}    
    

   
  








Related examples in the same category

1.WebClient.BaseAddress
2.WebClient.Credentials
3.WebClient.DownloadData
4.WebClient.DownloadFile
5.WebClient.DownloadString(Uri u)
6.WebClient.Headers
7.WebClient.OpenRead(String url)
8.WebClient.OpenWrite
9.WebClient.UploadData
10.WebClient.UploadValues