views:

375

answers:

3

Hi,

How can i read HTTP response headers from web service response in C#?

Best Regards,

Guy Bertental

+1  A: 

Can't you just refer to HttpContext.Current.Response.Headers in your webservice?
I'm not sure if that'll work.

Zyphrax
+1  A: 

If you're getting back an HttpResponse, you can just query the HttpResponse.Headers property.

Yuriy Faktorovich
+1  A: 

thanks for your replies, after digging the MSDN, all i needed to do is to override the GetWebResponse method and than 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;
    }
}

thanks anyways, Guy Bertental

Guy Bertental