November Happy Hour will be moved to Thursday December 5th.

CMS doesn't route through controller but website does

Vote:
 

Hi There,

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:

~/Views/MyBlock/Index.cshtml
~/Views/Shared/MyBlock.cshtml

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

Any Ideas?

Cheers Ben

#116588
Feb 03, 2015 7:51
Vote:
 

Hi Ben,

How is your block rendered, in a content area or is it a local block? Can you post the code from the controller?

Patrick

#116593
Feb 03, 2015 9:19
Vote:
 

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

namespace MyCompany.Controllers
{
	public class MyBlockController : BlockController<MyBlock>
	{
		public override ActionResult Index(MyBlock currentBlock)
		{
			if (currentBlock.FeaturedStyle)
				currentBlock.StyleAddons = "featured";

			currentBlock.ColumnCount = currentBlock.Buttons.IsNotNull() ? currentBlock.Buttons.Count : 0;

			return PartialView("~/Views/MyBlock/Index.cshtml",currentBlock);
		}
	}
}

Cheers Ben

#116677
Feb 03, 2015 23:41
Vote:
 

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?

#116694
Feb 04, 2015 9:19
Vote:
 

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.

#116698
Feb 04, 2015 9:46
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.