Reputation: 305
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
Upvotes: 1
Views: 64
Reputation: 414
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);
Upvotes: 1