Copied to clipboard

Flag this post as spam?

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


  • Romix2017 23 posts 183 karma points
    Oct 31, 2017 @ 18:53
    Romix2017
    0

    strong typed view model + hijacked route + custom route + virtualNodes

    Hello, guys! So my situation:

    • hijacked route, so all I have controllers for all my views the same as in regular mvc
    • strong typed view models each Umbraco.Web.Mvc.RenderMvcController has its own custom strong typed modelview
    • virtualNodes I have a tree in which I have a node just to gather together goods, like this home - goodsCategory - category1, category2 etc..., so in order for a path not be shown like www.mysite.com/goodsCategory/category1, but just as www.mysite.com/category1 I use virtualNodes for umbraco, so when I publish my item the link does not include /goodsCategory/ path.
    • custom route because by using virtualNodes and hijacked route I destroyed maproute, so I need to create one, no problem, I created the one.

      the problem

    after creating custom route, my controller is hit, but the problem is because I destroyed umbraco path for request, my controller does not get any currentContext and I got an errorenter image description here

    So how to handle this issue? I cannot cancel any of the mentioned above technics because I need all of them (strong typed view model + hijacked route + custom route + virtualNodes)

  • Romix2017 23 posts 183 karma points
    Nov 16, 2017 @ 19:42
    Romix2017
    100

    Well, the solution is this:

    1) Create route handler which will look for a needed object in DB/cache by using URL segment, and then will pass that object to route for injecting into a controller. enter image description here 2) In hijacked routes need to add route handler, so when route fires, then route handler inject model for the view. enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft