Copied to clipboard

Flag this post as spam?

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


  • Johan Plesner Hamann 105 posts 199 karma points
    Aug 04, 2016 @ 09:46
    Johan Plesner Hamann
    0

    Argument type 'Umbraco.Web.Models.RenderModel' is not assignable to model type 'Umbraco.Web.Models.RenderModel<model>'

    Umbraco 7.4.1

    Hey I am sitting with a strange problem. And I'm new to this SurfaceController...

    Argument type 'Umbraco.Web.Models.RenderModel' is not assignable to model type 'Umbraco.Web.Models.RenderModel<MovieRating.Models.FilmModel>' 
    

    enter image description here

      public class RatingController : SurfaceController
      {    
        [ChildActionOnly]
        public ActionResult GetRatingForm(int filmId)
        {  
            if (Members.IsLoggedIn())
            {
                var umbracoContext = UmbracoContext.ContentCache.GetById(filmId);
                var model = new FilmModel(umbracoContext);
                return PartialView("~/views/Partials/_RatingForm.cshtml", new RenderModel(model));
            }
            return null;
        }
     }
    
  • Toppers 31 posts 155 karma points
    Aug 04, 2016 @ 09:58
    Toppers
    0

    Suspect the problem is with your _RatingForm.cshtml View - I'm new to Umbraco and had the SAME problem yesterday...

  • Johan Plesner Hamann 105 posts 199 karma points
    Aug 04, 2016 @ 10:08
    Johan Plesner Hamann
    0

    _RatingForm.cshtml has this as inherits. Can you see what it could be?

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<MovieRating.Models.FilmModel>
    
  • Toppers 31 posts 155 karma points
    Aug 04, 2016 @ 10:12
    Toppers
    0

    How are you calling the GetRatingForm controller?

  • Johan Plesner Hamann 105 posts 199 karma points
    Aug 04, 2016 @ 10:19
    Johan Plesner Hamann
    0

    Like this

     @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<MovieRating.Models.FilmOverviewModel>
      ...
     @foreach (var film in Model.Content.Films)
     {
      ...
      @Html.Action("GetRatingForm", "Rating", new { filmId = film.Id })
      ...
     }
    
  • Toppers 31 posts 155 karma points
    Aug 04, 2016 @ 11:29
    Toppers
    1

    You've passed new RenderModel(model)) in your controller when it should be model...

  • Johan Plesner Hamann 105 posts 199 karma points
    Aug 04, 2016 @ 11:44
    Johan Plesner Hamann
    0

    It does not remove the erroris not assignable to model type. And I 've also tried. The website works. So I do not know what is happening or why...

  • Ronish Potiah 19 posts 171 karma points
    Aug 04, 2016 @ 12:11
    Ronish Potiah
    100

    Hello,

    from your controller method return the model of type FilmModel directly:

    return PartialView("~/views/Partials/_RatingForm.cshtml", model);
    

    Then in your partial view, inherits the "FilmModel" instead of "@inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @model FilmModel
    

    To access any property value do:

    @Model.PropertyName
    
  • Johan Plesner Hamann 105 posts 199 karma points
    Aug 04, 2016 @ 12:21
    Johan Plesner Hamann
    0

    Ronish Potiah Thank you very much :)

    And thank you Toppers


    FilmModel is of type IPublishedContent ( obvious? )

Please Sign in or register to post replies

Write your reply to:

Draft