How can I read the HTTP response headers from a web service response in C#?
After digging through MSDN, all I needed to do was to override the GetWebResponse
method, and then I could access the response headers:
public class MyWSProxy : HttpWebClientProtocol
{
protected override WebResponse GetWebResponse(WebRequest request)
{
System.Net.WebResponse wr = base.GetWebResponse(request);
// read a response header
object val = wr.Headers["key"];
return wr;
}
}