Try our conversational search powered by Generative AI!

Pages in ViewTemplateModelRegistrator not working



I have a page (OverviewPage) with a contentarea in which I want to put pages of type DetailPage:

[AllowedTypes(new[] { typeof(DetailPage) })]
public virtual ContentArea RoomTypes { get; set; }

These DetailPages can be placed under the OverviewPage in EPiServer. My OverviewPage class looks something like:

Availability = Availability.Specific,
Include = new [] { typeof(DetailPage) })]
[TemplateDescriptor(Tags = new[] { RenderingTags.OverViewPage })]
public class OverviewPage : PageData

My url /nl-nl/kamers-suites (OverviewPage) works and my url /nl-nl/kamers-suites/junior-room (DetailPage) also works.

As you can see, I defined a Tag on my OverviewPage and I would like that when I drag a Detailpage in my RoomTypes contentarea, this page is rendered differently.

In the past I have only done this with blocks and the ViewTemplateModelRegistrator, this worked fine. I have added the following line:

viewTemplateModelRegistrator.Add(typeof(DetailPage), new TemplateModel
Name = "DetailPageOnOverviewPage",
Inherited = true,
AvailableWithoutTag = false,
Tags = new[] { RenderingTags.OverViewPage },
Path = String.Format("~/Areas/{0}/Views/Shared/Pages/DetailPage.cshtml", areaName)

In EPiServer it says that the page in the content area cannot be rendered and the output in my browser is blank (literally nothing). In the logs I see the following error. I do not know for certain that it is related:

2014-06-23 15:34:21,232 [9] ERROR EPiServer.Global: 1.2.5 Unhandled exception in ASP.NET
System.Web.HttpException (0x80004005): The controller for path '/__browserLink/requestData/3244e3a31f40438cabcae6d155e8c1fd' was not found or does not implement IController.
bij System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType)
bij System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
bij System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
bij System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
bij System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
bij System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

hope somebody can help. Thanks in advance!

Jun 23, 2014 15:42

I think there are a few issues here.

First of all you are using a TemplateDescriptor on your model, but a TemplateDescriptors should be used on a controller. In your case I don't think you want a RenderingTag on your OverviewPageController, you probably want to use a tag on your contentarea to use a special rendering for the DetailPages dropped there.

Like this:

@Html.PropertyFor(x => x.CurrentPage.RoomTypes, new { Tag = "Overview"})

Second, if you want to render pages in a ContentArea you have define a partial view for these pages.

In your case you can register this partial view as:

viewTemplateModelRegistrator.Add(typeof(DetailPage), new TemplateModel
	Name = "DetailPageOnOverviewPage",
	Inherited = true,
	AvailableWithoutTag = false,
	Tags = new[] { "Overview" },
	Path = String.Format("~/Areas/{0}/Views/Shared/PagePartials/DetailPage.cshtml", areaName)


Jun 23, 2014 21:55

Hi Mark,

The Tag on my model was indeed a mistake and with moving it to my view it worked. Thank you!

Jun 24, 2014 8:38
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.