How to make a POST request with a minimum of scribbling? Interested in urlencoded and multipart . Like this:

 http.PostAsync("http://ya.ru", new PostData() { {"1", "2"}, {"3", "4"}, }); 

    1 answer 1

     new WebClient().UploadValues("http://ya.ru", new NameValueCollection() { {"1", "2"}, {"3", "4"} }); 
    • WebClient is not System.Net.Http.HttpClient? The question was demolished, and which one is better? And is it the same for HttpClient? - Smit Johnth 5:27 pm
    • @SmitJohnth HttpClient is the base class for rest services clients. He is able to serialize the data himself (to some extent). WebClient is just a helper for sending standard types of requests, but it’s better not to expect any strong typing or serialization from it. It all depends on what and where you are going to send requests. The question was about "less scribbling," so probably WebClient better. - PashaPash
    • Created a question, can you explain there? ru.stackoverflow.com/questions/438753/… - Smit Johnth 6:54 pm
    • @SmitJohnth I kind of already explained :) classes have a different purpose. Maybe someone else will answer. - PashaPash
    • Well, the appointment is the same - to make http requests :) - Smit Johnth