T
T
Tsiren Naimanov2015-12-28 17:37:55
API
Tsiren Naimanov, 2015-12-28 17:37:55

What's the difference between WebClient or Request + Response?

What's the difference between WebClient or Request + Response?
At the VK API, I wrote through the web client, all requests through DownloadString();
But, the API on github, written much better, with more functionality, comes with Request + Response, with given headers, and so on ...
What's the difference?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melz, 2015-12-28
@ImmortalCAT

I didn't quite understand the question, but HttpWebRequest gives you control over headers and so on. You can screw up quite a lot. If you have something tricky, then he is your friend.
There is also WebClient, this is a small abstraction over HttpWebRequest for the most popular actions. Less code.
Well, at the moment it's better to take HttpClient from NuGet. It is easier to test the code, you can mock, async, multithreads, more chips. But only under .Net 4.5+
In short, it depends on the version of the framework and platform.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question