Copied to clipboard

Flag this post as spam?

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


  • Ben Palmer 180 posts 866 karma points c-trib
    Aug 20, 2015 @ 14:09
    Ben Palmer
    0

    Umbraco 7.2.8 Compatibility

    I'm giving LeBlender a quick try as it sounds like a really useful project. However, I've run in to a problem when trying to render my view.

    I've created a grid editor 'LeBlender Accordion' through LeBlender and set up a view in the ~/Views/Partials/Grid/Editors directory called LeBlenderAccordion.cshtml.

    I've then used the accordion on a grid page which seems to work okay, the page tries to output my view and does hit it correctly. It's throwing the following error however:

    The model item passed into the dictionary is of type 'Lecoati.LeBlender.Extension.Models.LeBlenderModel', but this dictionary requires a model item of type 'Umbraco.Web.Models.RenderModel'.
    

    My view looks like this:

    @inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
    
    @if (Model.Items.Any())
    {
        <p>Test</p>
    }
    

    We wondered if this may be a compatibility issue with the latest Umbraco - we're using 7.2.8?

    My colleague also wondered if instead of using 'return View' (https://github.com/Lecoati/LeBlender/blob/master/Src/Lecoati.LeBlender.Extension/Controllers/LeBlenderController.cs#L77) you should be returning a PartialView?

    We replicated a similar issue on another project (without LeBlender) and using PartialView seemed to get around this error.

    Any help/suggestions would be great!

  • Jason Vickers 21 posts 115 karma points
    Oct 08, 2015 @ 20:21
    Jason Vickers
    0

    Also seeing this issue in 7.3

  • Alex 8 posts 131 karma points
    Oct 16, 2015 @ 19:43
    Alex
    0

    I'm also seeing this issue in 7.2.6

    Has anyone found a fix for this?

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Oct 16, 2015 @ 21:44
    Nik
    0

    Hi everyone,

    We've done something similar to what you appear to be doing, however we didn't get this issue.

    Our view has the same inherits statement, could you share what your config looks like for the editor for comparison please.

    Nik

  • Ben Palmer 180 posts 866 karma points c-trib
    Oct 17, 2015 @ 13:21
    Ben Palmer
    0

    Hi Nik,

    It was a while a go since I posted this and unfortunately, I had to move ahead without LeBlender. Which of course means that I can't post much in the way of configs etc.

    Hopefully someone else with the same issue will be able to help out in that respect.

  • Alex 8 posts 131 karma points
    Oct 19, 2015 @ 21:46
    Alex
    0

    Here is what the config looks like:

    {
            "name": "PaddedLinkBox",
            "alias": "PaddedLinkBox",
            "view": "/App_Plugins/LeBlender/editors/leblendereditor/LeBlendereditor.html",
            "icon": "icon-out",
            "render": "/App_Plugins/LeBlender/editors/leblendereditor/views/Base.cshtml",
            "config": {
                "editors": [
                    {
                        "name": "Title",
                        "alias": "title",
                        "propretyType": {},
                        "dataType": "0cc0eba1-9960-42c9-bf9b-60e150b429ae",
                        "description": "Title of the link box."
                    },
                    {
                        "name": "Description",
                        "alias": "description",
                        "propretyType": {},
                        "dataType": "c6bac0dd-4ab9-45b1-8e30-e4b619ee5da3",
                        "description": "Description text for the linkbox."
                    },
                    {
                        "name": "Link To",
                        "alias": "linkTo",
                        "propretyType": {},
                        "dataType": "a6857c73-d6e9-480c-b6e6-f15f6ad11125",
                        "description": "Where the link box should go to."
                    },
                    {
                        "name": "Photo",
                        "alias": "photo",
                        "propretyType": {},
                        "dataType": "93929b9a-93a2-4e2a-b239-d99334440a59",
                        "description": "Background photo for the link box."
                    }
                ],
                "frontView": ""
            }
        },
    

    It seems like it is throwing an exception somewhere in the controller method when it is called in LeBlender.cshtml:

    @(Html.Action("RenderEditor", "LeBlender", new { editorAlias = ViewData["editorAlias"], frontView = ViewData["frontView"], model = Model }))
    

    I bypassed controller in the Base.cshtml and just called the partial view directly and it started to render correctly confirming at least the exception is being thrown there for some reason.

    else
        {
            string viewName = string.IsNullOrEmpty(frontView) ? frontView = string.Format("/views/partials/grid/editors/{0}.cshtml", Model.editor.alias)
                                                              : frontView = string.Format("/Views/Partials/Grid/Editors/{0}.cshtml", frontView);
            <text>
                @*
                    Commented out because the controller is breaking something
                @Html.Partial("/App_Plugins/LeBlender/editors/leblendereditor/views/LeBlender.cshtml", blenderModel, datas)
                *@
                @Html.Partial(viewName, blenderModel)
            </text>
        }
    
  • Carl Jackson 139 posts 478 karma points
    Oct 20, 2015 @ 13:58
    Carl Jackson
    0

    As said in the original post - I think the issue would be solved by by returning PartialView() rather than View() from the controller.

    As to why this is an issue I don't know - related to the view inheritance I imagine from the error message, but I don't know why some would see this and not others.

    The correct return from the controller in question is PartialView and not View() anyway as it is only ever called as a child action so its worth trying.

    Thanks

    Carl

  • Carl Jackson 139 posts 478 karma points
    Oct 20, 2015 @ 14:04
    Carl Jackson
    0

    Hmmm...... thinking about this some more it may well be related to the _viewStart.cshtml file.

    If the Layout declaration points to a file with @inherits Umbraco.Web.Mvc.UmbracoTemplatePage in it then the error will be getting thrown from the layout page rather than the the partial view.

    By default Umbraco doesn't have a _viewstart which accounts for not being able to replicate the issue, Alex - do you have a _viewStart.cshtml file in you install, and does removing it fix the problem?

    Thanks

    Carl

  • Timo Perplex 13 posts 145 karma points c-trib
    Oct 20, 2015 @ 15:24
    Timo Perplex
    0

    This fixed the issue for me (for now):

    @{ Layout = null; }

  • Alex 8 posts 131 karma points
    Oct 20, 2015 @ 17:40
    Alex
    0

    I do have a _viewStart.cshtml in my project.

    I just tried Timo's suggestion and it worked. Adding

    @{
        Layout = "";
    }
    

    to the grid partials that you create did the trick.

    There's also a pull request on the GitHub project that added the layout fix to the examples as well. Returning a partial view might be the permanent fix for this though...

  • Carl Jackson 139 posts 478 karma points
    Oct 21, 2015 @ 10:30
    Carl Jackson
    0

    This will also fix the problem short term.

    However as the controller action is only ever called as a child the correct fix is to return PartialView() rather than View().

    It also means you don't have to repeat the code in every view just to override the _viewStart file.

    Thanks

    Carl

  • Carl Jackson 139 posts 478 karma points
    Oct 21, 2015 @ 10:41
    Carl Jackson
    0

    Pull request created for this

    https://github.com/Lecoati/LeBlender/pull/18

    Not sure if the leBlender team are active any more though to be honest as the repo hasn't been updated n 3 months and the Umbraco core is a few versions behind in the repo.

    Thanks

  • Antoine 176 posts 1494 karma points
    Oct 29, 2015 @ 17:11
    Antoine
    0

    Thanks Carl

    I have merged your Pull request, the team is active but doesn't have too much time recently. Anyway, we will try to release a new versiĆ³n soon.

Please Sign in or register to post replies

Write your reply to:

Draft