0

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?

Azri Zakaria
  • 1,324
  • 5
  • 23
  • 52
  • Can you share your response?And what do you want from response? – Yiyi You Dec 08 '20 at 02:49
  • I want to redirect to the payment gateway. But that payment gateway required `post method` so I not sure how can be done. The response I get is the payment gateway html page. – Azri Zakaria Dec 08 '20 at 03:29
  • If you want to show html page,you can try to return view() and pass the responseString to the view,use @html.Raw() to change the string to html code. – Yiyi You Dec 08 '20 at 05:13

0 Answers0