Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6136967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:40:07+00:00 2026-05-23T17:40:07+00:00

Hello guys I have a little trouble with the my method [HTTPost], please see

  • 0

Hello guys I have a little trouble with the my method [HTTPost], please see my code below:

MODELS (models Case and Person have more attributes than those presented here)

public class Case
     {
            public string caseNumber
            {
                get;
                set;
            }
        }


    public class Person
        {
            public string name
            {
                get;
                set;
            }

            public string lastName
            {
                get;
                set;
            }
        }


    public class ModelViewContainer {

            public Person Person { 
                get;
                private set;
            }

    public Case Case{ 
                get;
                private set;
            }

    public ModelViewContainer (Person person, Case casep)
            {

                Persona = persona;
                Case = casep;

            }

        }

IN MY CONTROLLER

        public ActionResult PresentView() {

            return View(new ModelViewContainer(new Person(),new Case()));
        }


        [HttpPost]    
        public ActionResult PresentView(ModelViewContainer model)  **<--never enters here**
        {
            if (ModelState.IsValid){
            ....
            }
            else
            return View(model);
        }

VIEW

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication1.Models.ModelViewContainer>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <% using (Html.BeginForm()) {%>
        <%: Html.ValidationSummary(true) %>

            Name
                <%: Html.TextBoxFor(model => model.Persona.nombre)%>
                <%: Html.ValidationMessageFor(model => model.Persona.nombre)%>

            LastName
                <%: Html.TextBoxFor(model => model.Persona.apellido)%>
                <%: Html.ValidationMessageFor(model => model.Persona.apellido)%>
            Case Number
                <%: Html.TextBoxFor(model => model.Case.caseNumber)%>
                <%: Html.ValidationMessageFor(model => model.Case.caseNumber)%>
            <p>
                <input type="submit" value="Create" />
            </p>

    <% } %>

</asp:Content>

The result error is: System.MissingMethodException: No parameter less constructor defined for this object.

Is it possible to capture the model in httpost or not? If not, how can i do? (Excuse my English) Please help me.

Edit– Corrections

public class ModelViewContainer {

            public Person Person { 
                get;
                set; //not private
            }

    public Case Case{ 
                get;
                set; //not private
            }

    public ModelViewContainer (Person person, Case casep)
            {

                Persona = persona;
                Case = casep;

            }

    public ModelViewContainer (){ //add parammeter less constructor
            }



        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:40:08+00:00Added an answer on May 23, 2026 at 5:40 pm

    ASP.Net MVC doesn’t work with immutable models; it doesn’t realize that it can just pass the property values as constructor parameters.

    Your ModelViewContainer needs a parameter-less constructor and writable properties.

    Alternatively, you could write your own ModelBinder that knows how to do that. (I do not recommend this option)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Guys! See I have been creating a code powered with ajax but it
Hello guys I have a question regardless a old code a client needed a
Hello guys I have 1675 line Code. Want to when user click button textbox.text
Hello guys I have this video tutorial on Ruby on Rails and I see
Hello guys I have a router (Belkin) so I wonder how can I see
Hello guys I have a doubt in django templates, I have two models with
Hello guys i have a little problem i get an error: File C:\Users\kokki\Desktop\gb1\main.py, line
Hello guys! I have been trying to create a if/else statement code in jQuery
Hello guys I have the following method: var usuario; usuario = UniapontaService.GetUsuarioUniapontaPlanejamentoEstrategico(x => x.IdUsuario
Hello guys sorry if the question looks stupid to you. i have 3 tables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.