I do integration with payment gateway, which required post method
. So I need to redirect from my page including post data
to the payment gateway application under https
Following by this answer on this questions:
Post Redirect to URL with post data
How to make an HTTP POST web request
I not able found the right answer for my problem.
I'am using razor pages. Here is my code snippet
public async Task<IActionResult> OnGetAsync(int id)
{
var values = new Dictionary<string, string>
{
{ "thing1", "hello" },
{ "thing2", "world" }
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("https://example/payment/v1/easy", content);
var responseString = await response.Content.ReadAsStringAsync();
return Content(responseString);
}
I successfully get the response, but when I do return Content(responseString);
. The page just show text only. Any idea how to solved this problem?