C# WebClient ResponseHeaders

Description

WebClient ResponseHeaders Gets a collection of header name/value pairs associated with the response.

Syntax

WebClient.ResponseHeaders has the following syntax.


public WebHeaderCollection ResponseHeaders { get; }

Example

The following code example downloads and displays the ResponseHeaders returned by a server.


using System;/* ww  w.j  a  va  2 s  .c  om*/
using System.Net;
using System.Net.Sockets;

public class Example
{
   public static void Main()
   {
         WebClient client = new WebClient();

      Byte[] pageData = client.DownloadData("http://www.java2s.com");
        WebHeaderCollection myWebHeaderCollection = client.ResponseHeaders;
        for (int i=0; i < myWebHeaderCollection.Count; i++)        
          Console.WriteLine (myWebHeaderCollection.GetKey(i) + " = " + myWebHeaderCollection.Get(i));

    
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient