In C# code I need to post form to other website for payment gateway, I can do it by adding some html tags to my webform and submitpage on body load. I I wants to do it in more proper way using HttpClient. but when i post my http call to client url with my data values. my page dont redirect me to payment website.is there any that my code work in same way like when i post my form manualy. Here is code snippet for form submisttion manualy:(its working)
<form action="https://somewebsite.com/someurl" method="POST" target="_blank"> <input name="token" value="MyTokenParameter" hidden = "true"/>
<input name="postBackURL" value="http://mywebsite.com/status.aspx" hidden = "true"/>
<input value="confirm" type = "submit" name= "pay"/>
</form>
Here is my C# code to submit the same data with httpclient:(its not redirecting user to payment website)
private async Task ProcessAsyncRequest()
{
using (var client = new HttpClient())
{
var values = new List<KeyValuePair<string, string>>();
values.Add(new KeyValuePair<string, string>("token", "MyTokenParameter"));
values.Add(new KeyValuePair<string, string>("postBackURL","http://mywebsite.com/status.aspx"));
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://somewebsite.com/someurl",content);
var responseString = await response.Content.ReadAsStringAsync();
Response.Write(responseString);
}
}
is it possible with httpclient to let user move to client site in response?