Why through
HttpClient
? It's much easier to do via the class
System.Net.HttpWebRequest
:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[
^].
The technique of getting a HTTP response is shown on the MSDN help page of its ancestor class
System.Net.HttpRequest
:
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[
^].
The method is blocking and synchronous, which is much better I think. You can explicitly execute it in a separate thread, is needed; and this form of asynchronous behavior is much better, because you reuse the same methods of threading and thread synchronization again and again.
—SA