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

  • SEARCH
  • Home
  • 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 992459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:16:16+00:00 2026-05-16T06:16:16+00:00

We had a View Model that looked like this: public class myViewModel { public

  • 0

We had a View Model that looked like this:

public class myViewModel {
    public Contract contract {get;set;}
    public Vendor vendor {get;set;}
}

public class Contract {
    public int contractID {get;set;}
    // ... various string properties
    public IList<ContractDetail> contractDetails {get;set;}
    pubilc Vendor vendor {get;set;}
}

Coming back from the form was the completed contract.

[HttpPost]
public ActionResult Edit(Contract contract) { ... }

Everything worked binding form post values back to to the contract parameter properties.

When we moved vendor in to Contract as a value object, all the first level “primitive” properties of the Contract fail to bind. All the IList<> properties are fine.

Any ideas or what more information we would need to solve this riddle? Is there any way to test how MVC binds form values back to object parameters? Is the solution something to do with Vendor not being an IList, i.e., why would the IList properties work fine?

Edit:

The fix was to absolutely specify the object hierarchy names in all fields, e.g., for vendor name to bind, it required a name of “Contract.vendor.name”. This prefix was done for us using the ViewModel, but not done for us using the Contract model. We ended up doing this for all view templates (partial views):

EditorFor(m => m.vendor, "Vendor", "Contract.vendor")

where “Vendor” is the name of the EditorTemplate “Vendor.ascx” and “Contract.vendor” prefixes all form field names.

I guess because the ViewModel nested all data, it caused MVC to prefix all properties correctly. That would mean that “loose” form fields not qualified by object prefixes will not bind to named parameter objects.

  • 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-16T06:16:17+00:00Added an answer on May 16, 2026 at 6:16 am

    Just download the mvc source code , do a project reference and debug through the default binder.

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

Sidebar

Related Questions

If I had a viewmodel that looked something like this public class AddressViewModel {
Assuming the following view model definition: public class MyObject { public string Name {
I had a Linq query against my Entity Framework model that was something like:
[QueryInterceptor(Somethings)] public Expression<Func<Something, bool>> OnSomethings() { // Code here } I had a view
It seems that others have had variations on this question, but from what I
I have errors in a model that are showing up in the view when
In Django/Python, if I had the following model class Model1: id = char field
I like the way model binding in django works: you send stuff that you
I was wondering whether anyone had any recommendations regarding populating multiple view models on
If I had 1000 rows, would a single-line separator make the table view bigger

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.