Copied to clipboard

Flag this post as spam?

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


  • xumix 17 posts 109 karma points c-trib
    Apr 08, 2014 @ 17:07
    xumix
    0

    No model == null in RenderMvcController action masterpge

    So, I have a controller like this:

    public class AccountController : RenderMvcController
        {
            public ActionResult Register()
            {
                return View();
            }}

    I have a corresponding Template, Contenttype  and layout for this controller/action.

    But I keep getting Model == null in the Layout page.

    My layout is simple and works fine in any other umbraco page:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }



        @Umbraco.RenderMacro("PageTitle")
        @Model.Content

    The view is simple too:

    @using System.Globalization
    @using ClientDependency.Core
    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        Layout = "RazorMaster.cshtml";
    }

     

    What can be the problem?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Apr 08, 2014 @ 17:46
    Jeroen Breuer
    100

    Hello,

    Try this in the controller:

    public class AccountController : RenderMvcController
        {
            public ActionResult Register(RenderModel model)
            {
                return CurrentTemplate(model);
            }}

    Jeroen

  • xumix 17 posts 109 karma points c-trib
    Apr 08, 2014 @ 18:22
    xumix
    0

    Thank you so much! The actual controller action now looks like this:

    public ActionResult Register(RenderModel model)
            {
                return CurrentTemplate(new RegisterModel(model.Content));
            }
  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Apr 08, 2014 @ 18:28
    Jeroen Breuer
    0

    If you want some other nice examples have a look at the Hybrid Framework. I do some funcky things with models and route hijacking in there.

    This blogs explains about base models which you can use in your master page: http://24days.in/umbraco/2013/hybrid-framework/

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft