I have the following POCO classes:
public class Location
{
public int LocationId { get; set; }
public string Name { get; set; }
publi
Here's the problem:
[HttpPost]
public ActionResult Create(LocationViewModel location)
Do you see it? It's the name of your action argument: location
.
Look at your view model now, it has a property named Location
:
public Location Location { get; set; }
This confuses the model binder. It no longer knows whether you need to bind the LocationViewModel
or its property.
So simply rename to avoid the conflict:
[HttpPost]
public ActionResult Create(LocationViewModel model)