I am able to loop through a response.Headers collection and display the value for each header like this.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(postDest);
//Set up the request with needed properties etc.
HttpWebResponse response = req.GetResponse() as HttpWebResponse;
for(int i= 0; i < response.Headers.Count; i++)
{
MessageBox.Show(response.Headers[i].ToString());
}
But how can I get the name Field-Name for each ResponseHeader?
Update:
If I do this I am able to get the Field-Name and the Value.
for (int i = 0; i < response.Headers.Count; i++)
{
MessageBox.Show("Field-Name is: " + response.Headers.GetKey(i).ToString() + " Value is: " + response.Headers[i].ToString());
}
you can use
response.Headers.GetValues(response.Headers.GetKey(i))