Gets a collection of header name-value pairs associated with this request.
using System;
using System.Net;
class MainClass
{
public static void Main()
{
WebRequest myWebRequest = WebRequest.Create("http://www.google.com");
WebResponse myWebResponse = myWebRequest.GetResponse();
for(int i=0; i < myWebResponse.Headers.Count; ++i)
Console.WriteLine("\nHeader Name:{0}, Header value :{1}",myWebResponse.Headers.Keys[i],myWebResponse.Headers[i]);
myWebResponse.Close();
}
}
Related examples in the same category