Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • andrew shearer 409 posts 517 karma points
    May 23, 2014 @ 07:08
    andrew shearer
    0

    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:

           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

  • andrew shearer 409 posts 517 karma points
    May 23, 2014 @ 07:11
    andrew shearer
    0

    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).

     

     

  • Lars-Erik Aabech 348 posts 1096 karma points MVP 4x c-trib
    May 23, 2014 @ 12:09
    Lars-Erik Aabech
    0

    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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies