I get the below error when trying to look at any block within the CMS. Everything renders fine in the website though. When I debug it doesn't hit the breakpoint in the controller I have.
Our site uses Alloy as it's base and I have added the block to either the two paths:
The view 'index' or its master was not found or no view engine supports the searched locations. The following locations were searched:~/Views/Preview/index.cshtml~/Views/Preview/index.vbhtml~/Views/Shared/index.cshtml~/Views/Shared/index.vbhtml~/Views/Preview/index.aspx~/Views/Preview/index.ascx~/Views/Shared/index.aspx~/Views/Shared/index.ascx
How is your block rendered, in a content area or is it a local block? Can you post the code from the controller?
So the blocks when displayed within the CMS UI get this issue, when in a ContentArea and as a block that you can drag and drop in to a ContentArea. They display perfectly when rendered on the website though.
The controller code I have tried many different variations to try and get it to work. Within the CMS the controller isn't routed to. Here's my code for the controller
public class MyBlockController : BlockController<MyBlock>
public override ActionResult Index(MyBlock currentBlock)
currentBlock.StyleAddons = "featured";
currentBlock.ColumnCount = currentBlock.Buttons.IsNotNull() ? currentBlock.Buttons.Count : 0;
Strange thing is that the MVC view engine tries to search to a path with the 'Preview' value and not your block name 'MyBlock'. Do you have a PreviewController and if you set a breakpoint does it hit?
Does the error occur when you view the whole page in the CMS or only the block?
Thanks so much for your response. Your post has helped me solve many hours of trial and error. One of our devs implemented this preview controller and the view (\preview\Index.cshtml) was missing hence this has occured. The solution was staring me in the face the whole time.