Copied to clipboard

Flag this post as spam?

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


  • Biagio Paruolo 1618 posts 1910 karma points c-trib
    Jul 12, 2016 @ 15:29
    Biagio Paruolo
    0

    Help on Error: Cannot bind source type RedTechNet.XYZ.Model.Cliente to model type Umbraco.Web.Models.RenderModel

    Hi, in the last version of Umbraco ( before not ), we have this error when passing custom model from surface controller to the view.

    The error appear when post data.

    Cannot bind source type RedTechNet.XYZ.Model.Cliente to model type Umbraco.Web.Models.RenderModel

    This is my code:

    Controller

    public ActionResult InserisciCliente()
            {
                var model = new RedTechNet.XYZ.Model.Cliente();
                return View("CNPNuovoCliente");
    
            }
    
            [HttpPost]
            public ActionResult InserisciCliente(RedTechNet.XYZ.Model.Cliente model)
            {
    
                return View("CNPNuovoCliente", model);
    
            }
    

    View:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using RedTechNet.XYZ.Model;
    
    @{
        Layout = "~/Views/CNPMasterReservedArea.cshtml";
    }
    
    @Html.Partial("cnpInsertCliente", new RedTechNet.XYZ.Model.Cliente())
    

    PartialView:

    @model RedTechNet.XYZ.Model.Cliente
    
    @using (Html.BeginUmbracoForm("InserisciCliente", "CNPDashBoard"))
    {
        @Html.EditorFor(x => Model)
        <input type="submit" />
    }
    

    Model:

    public class Cliente
        {
    
            public int Id
            {
                get; set;
            }
    
            public string CodiceFiscale
            {
                get; set;
            }
    
    
            public DateTime CreatedDateCliente
            {
                get;
                set;
    
            }
    
            public string CodiceAgenzia
            {
                get; set;
            }
    
    
            public string Cognome
            {
                get; set;
            }
    
            public string Nome
            {
                get; set;
            }
    
            public DateTime DataNascita
            {
                get; set;
            }
    
            public string LuogoNascita
            {
                get; set;
            }
    
            public Collaboratore Collaboratore
            {
                get; set;
            }
    
    
            public List<Pratica> Pratiche
            {
                get; set;
            }
        }
    

    Why? Thank you.

  • Renee Haas 18 posts 109 karma points
    Nov 10, 2016 @ 03:35
    Renee Haas
    0

    Did you ever solve this? I am having this same issue.

  • Biagio Paruolo 1618 posts 1910 karma points c-trib
    Nov 11, 2016 @ 07:42
    Biagio Paruolo
    0

    Hi, I solved with two simple workaround.

    1. I create a partial view and I passed my model I use normal Umbraco
    2. page and populate a model variable via code

    .

Please Sign in or register to post replies

Write your reply to:

Draft