Bruno
Bruno

Reputation: 4527

Get the response headers from a WebService call?

Is there a way to get the responde headers from a web service call on .net?

Upvotes: 2

Views: 2380

Answers (1)

Binoj Antony
Binoj Antony

Reputation: 16204

Write the following code from inside of the WebMethod (Web Service Method)

You may use a for loop to iterate through all the keys value pairs in the Header

int Count = HttpContext.Current.Request.Headers.Count;
for (int i = 0; i < Count; i++)
{
    string key = HttpContext.Current.Request.Headers.GetKey(i);
    string keyValue = HttpContext.Current.Request.Headers.Get(i);
    //Do something
}

Upvotes: 3

Related Questions