We have a page with various renderings on it. This page loads fine intermittently. One day it will work without any issues and the other day it stops working completely. When it stops working completely, the issue is
Exception: System.InvalidOperationException
Message: The view 'renderingname.cshtml' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/News/renderingname.aspx
~/Views/News/renderingname.ascx
~/Views/Shared/renderingname.aspx
~/Views/Shared/renderingname.ascx
~/Views/News/renderingname.cshtml
~/Views/News/renderingname.vbhtml
~/Views/Shared/renderingname.cshtml
~/Views/Shared/renderingname.vbhtml
The route has been registered properly before the OOTB route. The other views on the page never have this problem which reside in the same directory as renderingname.cshtml.
Here is the controller code running this component without the model code -
public ActionResult GetComponent()
{
//code to populate the model
return View("renderingname", model);
}
Any ideas on how to fix this?
Provide the full path for your rendering :
public ActionResult GetComponent()
{
//code to populate the model
return View("~/Views/Your_View_Folder/renderingname.cshtml",model);
}