{"id":90,"date":"2008-12-21T20:08:00","date_gmt":"2008-12-21T20:08:00","guid":{"rendered":"https:\/\/wdev-blog.azurewebsites.net\/index.php\/2008\/12\/21\/uploading-form-data-with-webrequest\/"},"modified":"2008-12-21T20:08:00","modified_gmt":"2008-12-21T20:08:00","slug":"uploading-form-data-with-webrequest","status":"publish","type":"post","link":"http:\/\/panahy.nl\/index.php\/2008\/12\/21\/uploading-form-data-with-webrequest\/","title":{"rendered":"Uploading form data with WebRequest"},"content":{"rendered":"<p>From the chapter 14 of O&#8217;Reilly&#8217;s <a href=\"http:\/\/www.albahari.com\/nutshell\/ch14.aspx\">C# in a NutShell<\/a>.<\/p>\n<pre><br \/><code><br \/>WebRequest req = WebRequest.Create (\"http:\/\/safari.oreilly.com\/search\");<br \/><br \/>req.Proxy = null;<br \/>req.Method = \"POST\";<br \/>req.ContentType = \"application\/x-www-form-urlencoded\";<br \/><br \/>string reqString<br \/>  = \"searchtextbox=webclient&searchmode=simple\";<br \/>byte[] reqData = Encoding.UTF8.GetBytes (reqString);<br \/>req.ContentLength = reqData.Length;<br \/><br \/>using (Stream reqStream = req.GetRequestStream())<br \/>  reqStream.Write (reqData, 0, reqData.Length);<br \/><br \/>using (WebResponse res = req.GetResponse())<br \/>using (Stream resSteam = res.GetResponseStream())<br \/>using (StreamReader sr = new StreamReader (resSteam))<br \/>  File.WriteAllText (\"SearchResults.html\", sr.ReadToEnd());<br \/><br \/>System.Diagnostics.Process.Start (\"SearchResults.html\");<br \/><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>From the chapter 14 of O&#8217;Reilly&#8217;s C# in a NutShell. WebRequest req = WebRequest.Create (&#8220;http:\/\/safari.oreilly.com\/search&#8221;);req.Proxy = null;req.Method = &#8220;POST&#8221;;req.ContentType = &#8220;application\/x-www-form-urlencoded&#8221;;string reqString = &#8220;searchtextbox=webclient&#038;searchmode=simple&#8221;;byte[] reqData = Encoding.UTF8.GetBytes (reqString);req.ContentLength = reqData.Length;using (Stream reqStream = req.GetRequestStream()) reqStream.Write (reqData, 0, reqData.Length);using (WebResponse res = req.GetResponse())using (Stream resSteam = res.GetResponseStream())using (StreamReader sr = new StreamReader (resSteam)) File.WriteAllText (&#8220;SearchResults.html&#8221;, sr.ReadToEnd());System.Diagnostics.Process.Start &hellip; <a href=\"http:\/\/panahy.nl\/index.php\/2008\/12\/21\/uploading-form-data-with-webrequest\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Uploading form data with WebRequest&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[75,76],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"Pouya Panahy","author_link":"http:\/\/panahy.nl\/index.php\/author\/pouya\/"},"uagb_comment_info":0,"uagb_excerpt":"From the chapter 14 of O&#8217;Reilly&#8217;s C# in a NutShell. WebRequest req = WebRequest.Create (\"http:\/\/safari.oreilly.com\/search\");req.Proxy = null;req.Method = \"POST\";req.ContentType = \"application\/x-www-form-urlencoded\";string reqString = \"searchtextbox=webclient&searchmode=simple\";byte[] reqData = Encoding.UTF8.GetBytes (reqString);req.ContentLength = reqData.Length;using (Stream reqStream = req.GetRequestStream()) reqStream.Write (reqData, 0, reqData.Length);using (WebResponse res = req.GetResponse())using (Stream resSteam = res.GetResponseStream())using (StreamReader sr = new StreamReader (resSteam)) File.WriteAllText (\"SearchResults.html\", sr.ReadToEnd());System.Diagnostics.Process.Start&hellip;","_links":{"self":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts\/90"}],"collection":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":0,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"wp:attachment":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}