{"id":568,"date":"2012-11-05T22:06:31","date_gmt":"2012-11-05T13:06:31","guid":{"rendered":"http:\/\/blog.belliny.net\/?p=568"},"modified":"2012-11-05T22:06:31","modified_gmt":"2012-11-05T13:06:31","slug":"c-http-post","status":"publish","type":"post","link":"https:\/\/www.belliny.net\/?p=568","title":{"rendered":"c#, http POST"},"content":{"rendered":"<p>http:\/\/www.hanselman.com\/blog\/HTTPPOSTsAndHTTPGETsWithWebClientAndCAndFakingAPostBack.aspx<\/p>\n<p>&nbsp;<\/p>\n<p>or&#8230;<\/p>\n<p>You could take a look at the\u00a0<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.net.webclient.aspx\" rel=\"nofollow\">WebClient<\/a>\u00a0class. It allows you to post data to an arbitrary url:<\/p>\n<pre><code>using (var client = new WebClient()) { var dataToPost = Encoding.Default.GetBytes(\"param1=value1&amp;param2=value2\"); var result = client.UploadData(\"http:\/\/example.com\", \"POST\", dataToPost); \/\/ do something with the result }<\/code><\/pre>\n<p>Will generate the following request:<\/p>\n<pre><code>POST \/ HTTP\/1.1 Host: example.com Content-Length: 27 Expect: 100-continue Connection: Keep-Alive param1=value1&amp;param2=value2<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.hanselman.com\/blog\/HTTPPOSTsAndHTTPGETsWithWebClientAndCAndFakingAPostBack.aspx &nbsp; or&#8230; You could take a look at the\u00a0WebClient\u00a0class. It allows you to post data to an arbitrary url: using (var client = new WebClient()) { var dataToPost = Encoding.Default.GetBytes(&#8220;param1=value1&amp;param2=value2&#8221;); var result = client.UploadData(&#8220;http:\/\/example.com&#8221;, &#8220;POST&#8221;, dataToPost); \/\/ do something with the result } Will generate the following request: POST \/ HTTP\/1.1 Host: example.com Content-Length: &hellip; <a href=\"https:\/\/www.belliny.net\/?p=568\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;c#, http POST&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-568","post","type-post","status-publish","format-standard","hentry","category-dev"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.belliny.net\/index.php?rest_route=\/wp\/v2\/posts\/568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.belliny.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.belliny.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.belliny.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.belliny.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=568"}],"version-history":[{"count":0,"href":"https:\/\/www.belliny.net\/index.php?rest_route=\/wp\/v2\/posts\/568\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.belliny.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.belliny.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.belliny.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}