Copied to clipboard

Flag this post as spam?

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


  • TheOriginal 22 posts 122 karma points
    Mar 29, 2016 @ 10:06
    TheOriginal
    0

    adding model to partial view

    I have created a controller that has models. I am trying to add the model to a partial view, passing in the result of a controller method.

    Controller / Model:

    public class Models : RenderModel
        {
            public class Posts : Models
            {
                public string postMessage { get; set; }
                public string profileImage { get; set; }
            }
        }
    

    View:

    @inherits UmbracoViewPage<UFaceAuth.Controllers.FacebookHelperController.Models.Posts>
    @{
    UFaceAuth.Controllers.FacebookHelperController facebook = new 
        UFaceAuth.Controllers.FacebookHelperController();
    }
    @Model
    

    Error:

    Cannot bind source type Umbraco.Web.Models.RenderModel`1[Umbraco.Web.PublishedContentModels.Home] to model type UFaceAuth.Controllers.FacebookHelperController+Models+Posts.

    Can anyone explain why this is happening please?

  • Daniele Florean 2 posts 72 karma points
    Mar 30, 2016 @ 14:39
    Daniele Florean
    0

    I'm experiencing the same problem in Umbraco 7.4.2, can't make route hijacking and custom template model working, with the same error. thinking in an umbraco bug... by now i've been forced to encapsulate all in a partial view and render it with Html.Action called from the main Template view, but this is totally useless and confusionary for the project. please if umbraco bug fix this soon, cause is really a problem not be able to use the standard umbraco inheritance

    Here's the code: View

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Custom.Models.MyCustomModel >
    

    Model

        public class MyCustomModel : RenderModel
    {
        public MyCustomModel (IPublishedContent content)
        : base(content)
        {
            //constructor
        }
    
    }
    

    Controller

    public class MyCustomController : RenderMvcController
    {
        public override ActionResult Index(RenderModel umbracoModel)
        {
    
            MyCustomModel model = new MyCustomModel(umbracoModel.Content);          
    
            return CurrentTemplate(model);
        }
    }
    
  • Matthew Kirschner 323 posts 611 karma points
    Mar 31, 2016 @ 20:53
    Matthew Kirschner
    0

    I'm having the same issue after upgrading to 7.4.2.

    I had custom routes that were using models inheriting from RenderModel. Now I'm getting the error:

    Cannot bind source type Umbraco.Web.Models.RenderModel to model type MyApp.Models.DocumentType.DefaultPageModel
    

    NOTE: My hijacked routes were working perfectly on 7.4.1

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Oct 25, 2017 @ 08:55
    Alex Skrypnyk
    0

    We have the same issue in Umbraco Cloud solution, version 7.5.14

  • Matthew Kirschner 323 posts 611 karma points
    Mar 31, 2016 @ 21:08
    Matthew Kirschner
    1

    This is a bug in Umbraco that is (supposedly) getting sorted out in 7.4.3.

    See the following post for a temporary solution: https://our.umbraco.org/forum/using-umbraco-and-getting-started/75998-update-to-742-all-custom-hijacked-controllers-stopped-working

Please Sign in or register to post replies

Write your reply to:

Draft