Get a collection of header name/value pairs associated with the response in CSharp
Description
The following code shows how to get a collection of header name/value pairs associated with the response.
Example
using System;/*from w w w . ja va 2 s . c o m*/
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.