The Get/post of HttpClient

Source: Internet
Author: User
Tags try catch urlencode

Finally make it almost clear, summed up as follows (omit the Try Catch), refer to from here

1.get:

A lump of URL with "code good" (UrlEncode need to handle) the parameters (can see) a piece sent to the server: eg:

 Public Async task<string> Getasync (string  uri) {    varnewnew TimeSpan (000)};     var await Httpclient.getstringasync (URI);     return content;}
Get Method

2.post:

A lump of url+ can not see the parameters of a piece into the data stream (UrlEncode could be processed in advance) sent to the server.

eg

  Public Asynctask<string> Postasync (stringURL, dictionary<string,string>para) {            varHttpClient =NewHttpClient {Timeout =NewTimeSpan (0,0,0, -)}; varContenta =NewFormurlencodedcontent (para); varResponse =awaithttpclient.postasync (URL, contenta); stringContent =awaitResponse.            Content.readasstringasync (); returncontent; }
Post Method

The Get/post of HttpClient

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.