Copied to clipboard

Flag this post as spam?

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


  • Flemming Swansson 1 post 21 karma points
    May 22, 2013 @ 19:18
    Flemming Swansson
    0

    Extend Umbraco with a custom MVC controller

    Hi,

    Iam trying to, create some kind of umbraco extension/plugin, i dont know if, i'll need to make a SurfaceController, or extend the RenderMvcController, and do a route hijacking.

    What i am trying to accomplish, is a catalog of smartphones. The catalog will, have a overview page, with all the phones listed, and a details page, where a single phone will be displayed. 
     
    It is also a requirement for me, that the url, is as clean as possible, so this single phone page, will need to be accessible, by this custom MVC Route /{Controller}/{Action}/{Brand}/{Model}/{EanCode}.

    The data for the catalog, is comming from a RestApi. The code and API calls to handle this, is already coded in clean MVC 4 controller and View, and is working outside, an Umbraco enviroment.

    I already tried to implement the catalog controller, with a Surface Controller, and tried to extend the Umbracos Global.asax file, to incorporate my own custom route. Everything works fine, when i request with a URL like this /phones/phone/Nokia/3110/1234567890123, inside a umbraco 6.0 installation. The controller gets called, via my own custom route, and the view gets returned like a normal MVC call would. but i dont know, how to wrap the returned view in a Umbraco template, and still maintaine the custom route.

    i use Umbraco 6, ASP.net 4.5 and MVC 4

    do anyone, have any suggestions ? :)

  • Ben Haynie 20 posts 50 karma points
    May 22, 2013 @ 19:30
    Ben Haynie
    0

    You might want to use a Plug In Surface Controller.  You can specify an Area, and get something fairly close to the URL you specified.  And, if you do it that way, I don't think you will need to hijack the route.

     

    our.umbraco.org/.../40797-V6-Surface-Controller-Plugin-template-errorNo-route-in-the-route-table-matches-the-supplied-values

  • Funka! 398 posts 661 karma points
    Jul 02, 2013 @ 01:01
    Funka!
    0

    My conclusion on this same type of problem has been that once you decide to use custom routes, you can no longer render templates through umbraco. Hopefully this will be possible some day in the future. Please keep us posted on whatever solution you ended up coming up with!

  • Funka! 398 posts 661 karma points
    Jul 04, 2013 @ 02:41
    Funka!
    0

    I rescind my statement from two days ago. Apparently this is now possible in v6.1.2, although you may still run into other difficulties as of yet unknown? Search for information on how to use a "ContentFinder" (introduced in umbraco 6.1+) perhaps and you may be able to achieve what you are trying. (Just passing on what I've heard, I've not actually done this yet.) Best of luck to you!

Please Sign in or register to post replies

Write your reply to:

Draft