Copied to clipboard

Flag this post as spam?

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


  • Limberg Michelsen 22 posts 99 karma points
    Jan 26, 2014 @ 19:42
    Limberg Michelsen
    0

    Combining MVC and Umbraco Razor Pages

    I have an Umbraco page with some content pages

    In addition to these pages, I need 4 razor pages that have nothing to do with Umbraco and have their own models and logic - standalone pages for filling out input forms.

    This is a check-out process where you go through the 4 pages.I am having some problems navigating to these directly and redirecting to them in the controller, because Umbraco is hijacking them.

    I would like some pointer on how it is best to accomplish this. I believe I can figure out the details myself, if someone can point me in the right direction with a suggestion and perhaps some links. Should I add some routing to circumvent Umbraco or is there another good way of doing this? Should I use custom controllers or something else?

    Thanks in advance for any tips

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 27, 2014 @ 12:10
  • Limberg Michelsen 22 posts 99 karma points
    Jan 28, 2014 @ 12:10
    Limberg Michelsen
    0

    Thanks for the information

    I have tried these things and I notice that this "Custom MVC Routes" requires me to have a Document Type.

    I am accessing the view directly - without a document type. I need my view to inherit the layout of the parent to get the design (this view uses @inherits Umbraco.Web.Mvc.UmbracoTemplatePage)

    I have tried different things and am now looking at SurfaceControllers, using this as inspiration: http://our.umbraco.org/documentation/Reference/Mvc/surface-controllers

    This works correctly for the URL http://localhost:50871/umbraco/surface/MySurface/Index using my controller and model, WITHOUT a layout.

    When I add the layout it says it is passing my model, but the layout page expects RenderModel, which I understand and would expect.

    I then follow the guide you sent me to solve this problem and make my custom model inherit from RenderModel. This requires me to add a custructor, like this: public Login(IPublishedContent content) : base(content) {  }

    And I call it from my controller like this: return View("CheckoutStep2", new Models.Login(CurrentPage));

    And now the return view gives me this error: "Cannot find the Umbraco route definition in the route values, the request must be made in the context of an Umbraco request" which I don't really understand.

    Note that I have tried different things too, without the SurfaceController etc., but I always run into problems - often the same problem with 'the request must be made in the context of an Umbraco request'

    My requirements are:

     - I want to call my view directly (without any document type) and I want the view to use the same layout-views as my Umbraco pages

     - I want this view to use a custom model

     - I want to submit this view to my controller, so I can perform login etc.

    Am I going about this the right way? What am I missing?

  • Limberg Michelsen 22 posts 99 karma points
    Jan 28, 2014 @ 14:57
    Limberg Michelsen
    0

    I think I am making this way too complicated

    At the moment I am looking into if this solves my problem: http://our.umbraco.org/documentation/reference/templating/mvc/forms

    Will post back :)

Please Sign in or register to post replies

Write your reply to:

Draft