1

I have a piece of code which refers to a specific view. The code is

private ActionResult PrepareSuccessResponse(PaymentProcessingContext paymentContext)
{
    this.RemoveLinkedMemberCookie();
    if (paymentContext.Provider.PaymentProviderType == "Worldpay")
    {
        return View("~/Areas/Payments/Views/Confirmation/WorldPayPaymentResponsePage.cshtml", paymentContext.ConfirmationUrl);
    }
    return Redirect(paymentContext.ConfirmationUrl);
}

This however returns the standard error of :

The view '~/Areas/Payments/Views/Confirmation/WorldPayPaymentResponsePage.cshtml' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Areas/Payments/Views/Confirmation/WorldPayPaymentResponsePage.cshtml

etc however in the same controller another view in a similar location is returned using these two functions

private const string FailedResponseViewPath = "~/Areas/Payments/Views/ResponseFailures/";
private static string GetViewPath(string viewName)
{
    return string.Format("{0}{1}.cshtml", FailedResponseViewPath, viewName);
}
private ActionResult PrepareFailedProcessingResponse(PaymentProcessingContext paymentContext)
{
    return View(GetViewPath("ProcessingError"), paymentContext);
}

The file structure looks like the image below with the file controller being the PaymentMvcController.cs

File Strucutre image

tereško
  • 58,060
  • 25
  • 98
  • 150
Charlie Hardy
  • 175
  • 1
  • 3
  • 14
  • Have you tried `return View("~/Areas/Payments/Views/Confirmation/WorldPayPaymentResponsePage.cshtml", paymentContext);`? (insetad of `paymentContext.ConfirmationUrl`) That's the only difference I can see. – Fildor Aug 30 '19 at 14:49
  • Your controllers folder is nested within the payments folder. You'll have to change your routing. Check the default route within the route config – user10728126 Aug 30 '19 at 15:21

1 Answers1

1

This is very similar to the question asked here - The view or its master was not found or no view engine supports the searched locations. The second argument "paymentContext.ConfirmationUrl" is understood as a path to a master page. To explicity make this the model, you should change the return to this:

return View("~/Areas/Payments/Views/Confirmation/WorldPayPaymentResponsePage.cshtml", model:paymentContext.ConfirmationUrl);
Mr. Cooper
  • 364
  • 3
  • 12