I have a custom controller for actions that inherits from UmbracoController and assumes umbraco context by doing this:
protected void RenderUmbracoContent(IPublishedContent content) { var model = new RenderModel(content, CultureInfo.CurrentUICulture); //add an umbraco data token so the umbraco view engine executes RouteData.DataTokens["umbraco"] = model; HttpContext.Items["pageID"] = Convert.ToString(content.Id); }
My question is there a best practice way of doing this now? thanks
to put this question in context: I have a "search" content item in my content tree that is used to manage the CMS aspects of the template, but the search actions are performed by a custom route (which uses the content item as its Umbraco context).
Umbraco Context for custom MVC Route in umb 6
hi
I have a custom controller for actions that inherits from UmbracoController and assumes umbraco context by doing this:
My question is there a best practice way of doing this now? thanks
to put this question in context: I have a "search" content item in my content tree that is used to manage the CMS aspects of the template, but the search actions are performed by a custom route (which uses the content item as its Umbraco context).
I'm not quite sure how to answer your question, but I'm sure you'll find this very useful. :)
https://github.com/umbraco/Umbraco4Docs/blob/master/Documentation/Reference/Templating/Mvc/custom-controllers.md#routing-via-template
is working on a reply...