title: How to post data and redirect to an external page?
body: <p>I am having trouble with posting data and redirecting to an external URL. The external URL is an online payment gateway that only accepts submitted form using <strong>POST</strong> method. </p>
  
  <p>A simple html form like below will work without any issues</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;form action="externalpage.url" method="post"&gt;
  &lt;input type="hidden" name="name1" value="1234"&gt;
  &lt;input type="hidden" name="name2" value="abcd"&gt;
  &lt;input type="submit" value="Submit Form"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But in my scenario, when the user clicks the button on my aspx page, I need to do some server side processing first, e.g. create a <code>NameValueCollection</code> object, before redirecting her to the payment gateway. </p>
  
  <p>I have tried to use the example from this link: <a href="http://www.codeproject.com/Articles/37539/Redirect-and-POST-in-ASP-NET" rel="nofollow noreferrer">http://www.codeproject.com/Articles/37539/Redirect-and-POST-in-ASP-NET</a>, but the page doesn't redirect to the external URL for some reason. The following line of code doesn't seem to do anything. </p>
  
  <pre><code>page.Controls.Add(new LiteralControl(strForm));
  </code></pre>