Copied to clipboard

Flag this post as spam?

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


  • Linx 98 posts 259 karma points
    Dec 18, 2023 @ 15:16
    Linx
    0

    Adding custom model throws error

    I'm using Umbraco 10. I create a Customer Document type with some fields i need to have for that page (something the content writers would enter)

    On this page i have a few custom fields that i need to capture from the end user and then do a post on the form.

    I create a custom customer model and add

    @Html.LabelFor(c=> c.Name)
    

    and it throws an error that the property cant be found. I then add a declaration to the top

    @model Models.Customer
    

    This resolves the above error but when the page loads it throws the error

    ArgumentException: Property 'ViewData' is of type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary1[[Umbraco.Cms.Web.Common.PublishedModels.Customer, CustomModels, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]', but this method requires a value of type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary1[[Customer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'. (Parameter 'viewContext')

    The controller it calls is inheriting from SurfaceController.

    Whats going wrong here?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies