November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
One guess is that something in PropertyFor will look for the currently routed content. In the case when the routing is for your non-episerver controller that routed content will not be set and hence nothing is outputed by PropertyFor.
If that is the case you could set the routed content link in your controller, something like (using namespace EPiServer.Web.Routing):
if (ContentReference.IsNullOrEmpty(ControllerContext.RequestContext.GetContentLink()))
{
ControllerContext.RequestContext.SetContentLink(ContentReference.StartPage);
}
Unfortunately, this doesn't seem to resolve the issue. I tried adding this to the OnActionExecuting method of the non-EPiServer controller, and it doesn't seem to change the behavior.
Anyone else have ideas on this? Surely I'm not the only one merging controllers like this?
This behavior is reproducable, if somewhat difficult to explain.
I have an existing MVC site, in to which I'm trying to add EPiServer. None of my existing controllers inherit from IRenderTemplate<T>, only my new EPiServer pages. My site start page is now an EPiServer page, which often links to pre-existing, non-MVC controllers.
To mix the two worlds, both the EPiServer (IRenderTemplate<T>) controllers, and my pre-existing controllers use the same _Layout.cshtml. That file grabs a static reference to the StartPage, then renders the blocks (like header, footer, and navigation). In this way, the content for the header/footer is controlled/editable by EPiServer, even for the pre-existing controllers, and can be edited by editing the Start Page in EPiServer.
The code in my _Layout.cshtml file looks like the following:.
@{
StartPage startPage = layoutViewModel.ContentRepository.Get<Mosaic.Models.Pages.StartPage>(EPiServer.Core.ContentReference.StartPage);
}
@Html.PropertyFor(x=>startPage.HeaderBlock)
Here is where the trouble starts. If I access one of my pre-exising controllers *first*, the block isn't rendered. No errors, just nothing is output. The "blank area" will persist until I visit a controller that *does* implement IRenderTemplate<T>, at which point, the header will display appropriately everywhere.
Is there a work around for this, so I can ensure the block will always render despite the load order?