Copied to clipboard

Flag this post as spam?

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


  • Alex Frost 3 posts 73 karma points
    Feb 22, 2019 @ 21:08
    Alex Frost
    0

    Good Evening,

    I am currently developing some functionality within Umbraco and have a question regarding Surface Controllers.

    I would like to basically return my own Model into a View created within Umbraco.

    For example

    I have created a DocumentType of "Home" and a Template of "Home" within the backend and I have a SurfaceControler then returns the below.

    return View("~/Views/Home.cshtml", model);

    Error I'm getting is

    The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'Namespace.Model'.

    I can use

    @Html.Action("Name", "Names") and this works fine.

    So basically I need to be able to pass my "Namespace.Model" into a normal Umbraco created View.

    @model Namespace.ViewModels.NameViewModel

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @using ContentModels = Umbraco.Web.PublishedContentModels;

    I hope this makes sense.

    Thank you. Alex

  • Nigel Wilson 944 posts 2076 karma points
    Feb 25, 2019 @ 06:20
    Nigel Wilson
    0

    Hi Alex

    To help with understanding the issue, are you able to post complete code snippets ?

    So your view, your partial, your controller - appreciate it might be a bit of code, but it makes it easier to track down where the issue is.

    Cheers

    Nigel

Please Sign in or register to post replies

Write your reply to:

Draft