Copied to clipboard

Flag this post as spam?

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


  • Beau D'Amore 29 posts 70 karma points
    Jun 18, 2014 @ 20:39
    Beau D'Amore
    0

    Google-friendly URLs and Custom Controllers

    I'm very new to Umbraco so please forgive.

    I need to have friendly URLs in my site. URLs like maryruns.com/umbraco/Surface/TrackHistory/Tracks/123. (preferably without the 'umbraco/surface' but that's another matter)

    NOT like maryruns.com/members and then use a partialview to call my SurfaceController.. this DOES WORK, but it is not acceptable if I want the friendly URLs. I have several other threads basically asking the same thing, but I think the complexity of the world obfuscates my questions...

    BACKGROUND:

    -v7

    -I'm using SQL Server DB with a LINQtoSQLClasses.dbml to access my custom tables for GPS location data. (These tables were added manually to the DB and are used by APIControllers for the iOS app to push the GPS data from a runner's track up to the server, which works well. There are no matching doc-types, not sure if they're needed in some way)

    -Using the Umbraco starter kit

    So, I made a surfaceController Called 'TrackHistory' with an action called 'Tracks' that takes an UmbracoMemberID as a QS param. so hitting maryruns.com/TrackHistory/Tracks/123 works GREAT, HOWEVER it doesn't have any styling. It's a bare skeleton of the action action output like you see here.


    I need this URL to work WITH the _Layout.cshtml but it does not.

    If I have @inherits UmbracoTemplatePage in my view, it bombs because it is not the strongly-typed model and model.whatever is unaccessable in my view

     

     

     

    if I have @inherits Umbraco.Web.Mvc.UmbracoViewPage<IEnumerable<MaryRuns.Models.TRACK>>

    OR

    If I have @model IEnumerableTRACKLocation> which is my strongly-typed model, it works fine (albeit bare like the above pic) until I then try to add:

    @{   

        Layout = "_Layout.cshtml";

    }

    In order to try to wrap the controller in the layout so it 'looks pretty' and has the menu, etc... however... upon adding the above line it's telling me:

    The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MaryRuns.Models.TRACK]', but this dictionary requires a model item of type 'Umbraco.Web.Models.RenderModel'.

    Apparently, I need the rendermodel AND my custom model... how is this possible?

    How do I achieve the desired result?

    How do I use maryruns.com/TrackHistory/Tracks/123 and still get my results wrapped in the layout?

    I've read over so many articles my mind is mush currently... How do i get BOTH Umbraco.web.models.rendermodel AND my custom model in the same view so I can still use things like:

     <title>@Umbraco.Field("title", altFieldAlias: "pageName") | @Umbraco.Field("siteName", recursive: true)title>

     

       ?????? Because if I include the line {Layout="blah.cshtml"} it errors on anything with @Umbraco in front of it since the RenderModel is not present... how do i get them BOTH to be present in my controller?

    Do I use a RenderMVCController instead of a surfaceController? If so, how?

    I read somewhere that if I name my RenderMVCController the same name as my content page, it will automagically be picked up and will run the code in the controller... I tried this and got ZERO.. I made a content page called 'Members' then made a controller called 'Members', put breakpoints alllllllllll over that controller and it was never hit at all when I go to site.com/members ???,... this is so inconvenient... 3 days at this

    Please help me sort this out. I'm bouncing around between 100 articles I just don't understand. This has gone on for 3 days straight now. Not getting anywhere...

    again, just to make sure it's understood, I DO NOT want to use HTML.Action and render the SC INSIDE an existing content page. This is NOT acceptable since it will not show the google-friendly URLs...

    Thanks much

  • Jonathan Richards 288 posts 1742 karma points MVP
    Jun 19, 2014 @ 10:54
    Jonathan Richards
    0

    You might want to take a look at my package projects/website-utilities/autoroutetemplate, its designed as a non-coding solution to handle friendly URLs easily within Umbraco 6 & 7.

     

     

  • Beau D'Amore 29 posts 70 karma points
    Jun 19, 2014 @ 14:39
    Beau D'Amore
    0

    Thank you for the response, but this is not what I need since this has nothing to do with using/merging Umbraco's 'RenderModel' and my custom model.

  • Jonathan Richards 288 posts 1742 karma points MVP
    Jun 19, 2014 @ 15:04
    Jonathan Richards
    0

    This is just my 2 pence, and i've not done any specific research to your problem, but i wanted to achieve similar response, which is why I ended up with that package. My memory is that most of the umbraco page life cycle is private and without hacking stays that way. Umbraco have added IContentFinder to do your own routing within the umbraco framework.  Im sorry if Im unable to give you a direct answer using MVC routing, and if you do find a solution, i would love to read a post on it.

Please Sign in or register to post replies

Write your reply to:

Draft