Read response header from WebClient in C#

I'm trying to create my first windows client (and this is my fist post her), there shall communicate with a "web services", but i have some trouble to read the response header there is coming back. In my response string do I received a nice JSON document back (and this is my next problem), but i'm not able to "see/read" the header in the response, only the body.

Below is the code i'm using.

        WebClient MyClient = new WebClient();
        MyClient.Headers.Add("Content-Type", "application/json");
        MyClient.Headers.Add("User-Agent", "DIMS /0.1 +http://www.xxx.dk");
        var urlstring = "http://api.xxx.com/users/" + Username.Text;
        string response = MyClient.DownloadString(urlstring.ToString());
Jon Skeet
people
quotationmark

If you want to see the full response, I suggest you use WebRequest/WebResponse instead of WebClient. That's a more low-level API - WebClient is meant to make very simple tasks (such as downloading the body of a response as a string) simple.

(Or in .NET 4.5 you could use HttpClient.)

people

See more on this question at Stackoverflow