0

I have an Sitecore app (9.0.2) MVC application, in which I send to the Controller a FormCollection object, with an Ajax call (because I create dynamically tabs with in View).

On the Controller, I have a redirect to a payment service:

WebUtil.Redirect(new RealExService().RedirectPost(postData, Sitecore.Configuration.Settings.GetSetting("realexurl","https://pay.realexpayments.com/pay")).AbsoluteUri);
(...)
return View("~/Views/Complete.cshtml", viewModel);

The issue is that when the redirect happens, Request Method automatically changes to OPTIONS and thus I get a status code of 403 and the payment form is not shown.

I have switched the POST request from AJAX call to MVC form submit and it works as expected. (with the price of losing dynamic content on the View)

Any ideas?

Thank you.

  • Did you try returning a RedirectAction? that's how you're supposed to redirect from controller actions – Mark Cassidy Jun 11 '19 at 9:46
  • Is the OPTIONS request the CORS preflight request? If so you will need to ensure the payment service handles this appropriately. – Jeroen Jun 11 '19 at 14:05
  • @Jeroen you are right, the payment service needs to handle my request, but this is not possible, so I fixed the flow in my code. – iusmar Jun 13 '19 at 11:47
  • @MarkCassidy no, I did not try to return a RedirectAction. I replaced the return View () with Content(). – iusmar Jun 13 '19 at 11:48
0

I have fixed the issue by replacing

WebUtil.Redirect(new RealExService().RedirectPost(postData, Sitecore.Configuration.Settings.GetSetting("realexurl","https://pay.realexpayments.com/pay")).AbsoluteUri);
(...)
return View("~/Views/Complete.cshtml", viewModel);

with

return Content(new RealExService().RedirectPost(postData, Sitecore.Configuration.Settings.GetSetting("realexurl", "https://pay.realexpayments.com/pay")).AbsoluteUri);

and in the Ajax call:

success: function (response, textStatus, jQxhr) 
{
   window.location.href = response;
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.