Hey Folks, I'm trying to POST data to an external url using HttpWebRequest, then i need to redirect the user to the external url where which i just POSTed my data, can this be achieved on the first place ?
Well, the redirect should be fairly standard - just a regular ASP.NET redirect.
Re doing a POST; that is fine - but it would be even easier to just use WebClient
:
using (WebClient client = new WebClient())
{
client.UploadData(address, "POST", data);
}
(other methods and overloads for different use-cases)
Sure, that's quite possible.
Depending on what data you need to post, the System.Net.WebClient class might be simpler than the HttpWebRequest. It can upload strings and files with one method call.
Unless there is something that needs to be done on the server side you should probably do this from JS on the client side.
Just submit a form programtically using JS that will take care of both the posting and the redirect.
The easiest way to do this would be just to set the form's action attribute:
<form method="post" action="url/to/post/data/to">
....
</form>
Then the data and the user will be sent to your URL without you having to do anything programmatically.