Copied to clipboard

Flag this post as spam?

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


  • Mike Cave 24 posts 162 karma points
    Jan 22, 2018 @ 09:14
    Mike Cave
    0

    ERROR: 'Incorrect model item passed' - even though it is correct part 1

    ERROR:

    The model item passed into the dictionary is of type 'Umbraco.Works.BookmakerUploadViewModel', but this dictionary requires a model item of type 'Umbraco.Works.BookmakerUploadViewModel'.

    This is weird as the dictionary wants the exact same model as it is complaining about... Please help I am at my wits end.

    This is working fine in development but not when deployed. The rest of the site is working when deployed, just not this page: /operators/bookmaker-upload.

    any help is gratefully received.

    I TRIED TO POST THE WHOLE ERROR BUT THE POSt WOULD NOT FINISH: here is the main part of the code where it is failing:

    my umbraco template for BookmakerUploadTemplate:


    @using ClientDependency.Core.Mvc @using Umbraco.Web @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{ Layout = "Master.cshtml"; var url = Request.Url.AbsolutePath.ToString(); if (url == "/umbraco/RenderMvc") { url = Request.UrlReferrer.ToString(); } }

    @Umbraco.RenderMacro("Breadcrumbs")
    @Html.Action("RenderBookmakerUpload", "BookmakerUploadSurface")

    which redirects to my controller with the entry code of:

    namespace Umbraco.Works { public class BookmakerUploadSurfaceController : SurfaceController { public BookmakerUploadSurfaceController() { // // TODO: Add constructor logic here // }

        public ActionResult RenderBookmakerUpload()
        {
            return PartialView("BookmakerUpload", new BookmakerUploadViewModel());
        }
    
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult HandleBookmakerUpload(BookmakerUploadViewModel model)
        {
    

    My model is in a class called AuthViewModels.cs and is declared:

    public class BookmakerUploadViewModel
    {
        public string FileName { get; set; }
        public bool Success { get; set; }
        public string UploadError { get; set; }
        public HttpPostedFileBase attachment1 { get; set; }
    }
    

    In development I have no issues with the project, only when I have deployed to the web.

    any clues? the full error message is:

    Server Error in '/' Application.

    The model item passed into the dictionary is of type 'Umbraco.Works.BookmakerUploadViewModel', but this dictionary requires a model item of type 'Umbraco.Works.BookmakerUploadViewModel'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'Umbraco.Works.BookmakerUploadViewModel', but this dictionary requires a model item of type 'Umbraco.Works.BookmakerUploadViewModel'.

    Source Error:

    Line 22:

    Line 23:
    Line 24: @Html.Action("RenderBookmakerUpload", "BookmakerUploadSurface") Line 25:
    Line 26:


    I will post the source error next as I cant post the whole message to the forum as it hangs.

    Thanks for any help

  • Mike Cave 24 posts 162 karma points
    Jan 22, 2018 @ 11:14
    Mike Cave
    100

    Hi Guys,

    I did a search here and found the same error. I followed Georges advice and it has solved my issue!

    Many thanks to George for posting his answer which can be found here:

    https://our.umbraco.org/forum/templates-partial-views-and-macros/89002-invalid-model-when-rendering-through-surfacecontroller-behind-a-load-balancer

    Thanks

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Jan 22, 2018 @ 11:15
    Alex Skrypnyk
    0

    Hi Mike

    Thanks for sharing with our community! #h5yr!

    /Alex

Please Sign in or register to post replies

Write your reply to:

Draft