Copied to clipboard

Flag this post as spam?

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


  • John ben 78 posts 293 karma points
    Mar 10, 2017 @ 17:13
    John ben
    0

    adding model to partial view Error

    Hi all, 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. enter image description here enter image description here enter image description here

    I created a controller that return a model, i m trying to add the model to a partial view which i call

    I m getting this error

    Cannot bind source type CourDeCassation.Models.jurisprudenceVM to model type Umbraco.Web.Models.RenderModel.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Mar 11, 2017 @ 07:44
    Dave Woestenborghs
    0

    Hi Youness,

    I think you are calling your partial using this syntax :

    @Html.Partial("YourViewName")
    

    if you are using a controller you need to use this syntax

    @Html.Action("ActionName","ControllerName")
    

    Dave

  • John ben 78 posts 293 karma points
    Mar 13, 2017 @ 10:20
    John ben
    0

    Hi dave

    i m already using @Url.Action("RenderdetailJurisprudence", "Jurisprudence", new { id = @item.NumArret }) , i don't see why it would give me that error if it was the problem.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Mar 13, 2017 @ 10:57
    Dave Woestenborghs
    0

    Hi Youness,

    Can you post the code of your controller ? Not just the code of the action ?

    Dave

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Mar 13, 2017 @ 11:02
    Michael Latouche
    0

    Hi Youness,

    Maybe a silly question, but is this really a partial view, or a "plain" view? I see you are specifying a layout, which seems to indicate it is a plain view. In that case I guess your controller should return a View, not a PartialView?

    Cheers,

    Michael.

  • John ben 78 posts 293 karma points
    Mar 13, 2017 @ 11:17
    John ben
    0

    I changed my code he are some print image My controller My model

    the page which where i call my controller enter image description here

    Detail page enter image description here

    i get my informations from anothers database, i searched for my problem

    i found this topic :

    https://our.umbraco.org/forum/using-umbraco-and-getting-started/75998-update-to-742-all-custom-hijacked-controllers-stopped-working

    i tried using render model in my model and using RenderMvcController but when i try call my controller i don t get the url in question.

  • John ben 78 posts 293 karma points
    Mar 13, 2017 @ 11:22
    John ben
    0

    when i change @inherits UmbracoViewPage

    @{ Layout = "~/Views/WebBase.cshtml"; }

    to @model jurisprudenceVM it work fine but with no layout page

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Mar 13, 2017 @ 11:24
    Dave Woestenborghs
    0

    I see the problem. You are doing @Url.Action to a surface controller action.

    Surface controller actions are not tight to a content request. You should think of a surface controller action as ChildOnlyAction in pure MVC terms.

    https://our.umbraco.org/documentation/Reference/Templating/Mvc/child-actions

    Some more info on surface controllers : https://our.umbraco.org/documentation/reference/routing/surface-controllers

    What you probably need is some custom routing or route hijacking.

    Read more about it here : https://our.umbraco.org/documentation/reference/routing/custom-controllers

    Dave

  • John ben 78 posts 293 karma points
    Mar 13, 2017 @ 11:49
    John ben
    0

    Hi Dave.

    Well, still stuck with this problem for 2days, buts thanks for the links.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Mar 13, 2017 @ 11:58
    Dave Woestenborghs
    0

    Hi Youness,

    The problem is you are trying to do traditional MVC routing in Umbraco... and that conflicts with routing setup by Umbraco.

    I think this blog article should get you started.

    https://umbraco.com/blog/a-practical-example-of-route-hijacking-in-umbraco/

    And here are the source code gists from the article : https://gist.github.com/nul800sebastiaan/8641249

    Dave

  • John ben 78 posts 293 karma points
    Mar 13, 2017 @ 12:08
    John ben
    0

    Hi dave,

    Already tried that solution, it seems RenderMvcController does'nt give the rights to redirect when i used my urlaction

  • John ben 78 posts 293 karma points
    Mar 13, 2017 @ 17:57
    John ben
    0

    Well, still stuck with the same problem ,i followed all topics and tried them all , i couldn't find a solution, would apreaciate if someone can give me some tips

    Best regard,

    Youness Ben

  • John ben 78 posts 293 karma points
    Mar 14, 2017 @ 09:34
    John ben
    101

    Issue fixed, i created a controlle and a related view where i called my masterpage and in that view i used a partialview to display my data with my model, and for the problem why my urlaction didn't give me an url is because i used @Url.Action("RenderdetailJurisprudence", "jurisdetail", new { id = @item.NumArret }) instead of : @Url.SurfaceAction("RenderdetailJurisprudence", "jurisdetail",new {[email protected]} )

Please Sign in or register to post replies

Write your reply to:

Draft