<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ardent Dev &#187; Code</title>
	<atom:link href="http://ardentdev.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://ardentdev.com</link>
	<description>For the Love of Code</description>
	<lastBuildDate>Mon, 19 Apr 2010 14:31:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>POSTing to a webpage and using it&#8217;s response (HttpWebRequest and HttpWebResponse)</title>
		<link>http://ardentdev.com/posting-to-a-webpage-and-using-its-response-httpwebrequest-and-httpwebresponse/</link>
		<comments>http://ardentdev.com/posting-to-a-webpage-and-using-its-response-httpwebrequest-and-httpwebresponse/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 20:44:56 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://blog.ardentdev.com/index.php/2006/12/20/posting-to-a-webpage-and-using-its-response-httpwebrequest-and-httpwebresponse/</guid>
		<description><![CDATA[
    You might encounter a situation where you need to Post to a web page and read it&#8217;s
    response.
    Here&#8217;s a function that uses System.Net.HttpWebRequest and System.Net.HttpWebResponse
    to do just that.
  

    

      ' [...]]]></description>
			<content:encoded><![CDATA[<div>
    You might encounter a situation where you need to Post to a web page and read it&#8217;s
    response.</p>
<p>    Here&#8217;s a function that uses System.Net.HttpWebRequest and System.Net.HttpWebResponse
    to do just that.
  </p></div>
<div>
    <code></p>
<pre style="font: 9pt Courier New;">
      ' Usage:
      '   Dim xmlDoc As Xml.XmlDocument
      '   xmlDoc.Load(MakeHttpRequest( _
                           "request=listPersons&amp;filter=last(a*)", _
                           "/requestManager.php", _
                           "application/x-www-form-urlencoded")) 

      Protected Function MakeHttpRequest(
                                   ByVal data As String, _
                                   ByVal url As String, _
                                   ByVal contentType As String) _
                                   As System.IO.Stream
        Dim retVal As System.IO.Stream 
        Dim httpRequest As System.Net.HttpWebRequest 
        Dim httpResponse As System.Net.HttpWebResponse 
        Dim encoding As New System.Text.UTF8Encoding
        Dim uri As New System.Uri(url) 
        Dim postBytes As Byte() postBytes = encoding.GetBytes(data)      
        httpRequest = CType(System.Net.HttpWebRequest.Create(uri), _
                                     System.Net.HttpWebRequest)      
        httpRequest.ContentLength = postBytes.Length 
        httpRequest.Method = "POST" 
        httpRequest.ContentType      = contentType 
        Dim postStream As System.IO.Stream = _
                                 httpRequest.GetRequestStream()      
        postStream.Write(postBytes, 0, postBytes.Length) 
        postStream.Close() 
        httpResponse = CType(httpRequest.GetResponse(), System.Net.HttpWebResponse) 
        retVal = httpResponse.GetResponseStream()
        Return retVal
      End Function
      </pre>
<p>    </code>
  </div>
<div>
    Variation: If the webpage you are calling expects xml you could easily replace and
    pass a valid xml string as data<br />
    replace<br />
    <code>httpRequest.ContentType = "application/x-www-form-urlencoded"</code>
    <br />
    with<br />
    <code>httpRequest.ContentType = "text/xml"</code></p>
<p>    <i>You could even go further and return an xml document if the expected datatype is
      &#8220;text/xml&#8221;.</i>
    
  </div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://ardentdev.com/posting-to-a-webpage-and-using-its-response-httpwebrequest-and-httpwebresponse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brain Teaser:  What Does This JavaScript Do?</title>
		<link>http://ardentdev.com/brain-teaser-what-does-this-javascript-do/</link>
		<comments>http://ardentdev.com/brain-teaser-what-does-this-javascript-do/#comments</comments>
		<pubDate>Thu, 05 Jan 2006 03:31:50 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://blog.ardentdev.com/index.php/2006/01/05/brain-teaser-what-does-this-javascript-do/</guid>
		<description><![CDATA[   JavaScript is one of those technologies that you can use for years knowing only very&#160;little   about it.&#160; Do you know what the following &#60;script&#62; block will do?&#160;   Post your guess as a comment before you test it out!
   &#60;script&#62;
   (function()   {  [...]]]></description>
			<content:encoded><![CDATA[<p>   JavaScript is one of those technologies that you can use for years knowing only very&nbsp;little   about it.&nbsp; Do you know what the following &lt;script&gt; block will do?&nbsp;   Post your guess as a comment before you test it out!</p>
<p>   <font face="Courier New">&lt;script&gt;</font></p>
<p>   <font face="Courier New">(function()<br />   {<br />   &nbsp; function A() { document.write(A) }</font></p>
<p>   <font face="Courier New">&nbsp; A();<br />   })()</font></p>
<p>   <font face="Courier New">&lt;/script&gt;</font></p>
<p>
<hr />
<div>   Read a great book: <a href="http://www.amazon.com/gp/product/0066620996?ie=UTF8&amp;tag=derehatcblo0e-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0066620996">Good   to Great: Why Some Companies Make the Leap&#8230; and Others Don&#8217;t</a><img src="http://www.assoc-amazon.com/e/ir?t=derehatcblo0e-20&amp;l=as2&amp;o=1&amp;a=0066620996" width="1" height="1" border="0" alt="" /> by   Jim Collins </div>
]]></content:encoded>
			<wfw:commentRss>http://ardentdev.com/brain-teaser-what-does-this-javascript-do/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
