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 POST method.
A simple html form like below will work without any issues
<html>
<body>
<form action="externalpage.url" method="post">
<input type="hidden" name="name1" value="1234">
<input type="hidden" name="name2" value="abcd">
<input type="submit" value="Submit Form">
</form>
</body>
</html>
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 NameValueCollection
object, before redirecting her to the payment gateway.
I have tried to use the example from this link: http://www.codeproject.com/Articles/37539/Redirect-and-POST-in-ASP-NET, but the page doesn't redirect to the external URL for some reason. The following line of code doesn't seem to do anything.
page.Controls.Add(new LiteralControl(strForm));