DefaultModelBinder not binding nested model

Viewed 13669

Looks like others have had this problem but I can't seem to find a solution.

I have 2 Models: Person & BillingInfo:

public class Person
{
 public string Name { get; set;}
 public BillingInfo BillingInfo { get; set; }
}

public class BillingInfo
{
 public string BillingName { get; set; }
}

And I'm trying to bind this straight into my Action using the DefaultModelBinder.

public ActionResult DoStuff(Person model)
{
 // do stuff
}

However, while the Person.Name property is set, the BillingInfo is always null.

My post looks like this:

"Name=statichippo&BillingInfo.BillingName=statichippo"

Why is BillingInfo always null?

5 Answers
Related