Is there an alternative for [Bind(Exclude = \"Id\")] (Related Question) ?
Could I write a model binder?
As an addition to the existing answers, C# 6 makes it possible to exclude the property in a safer way:
public ActionResult Edit(Person person)
{
ModelState.Remove(nameof(Person.Id));
if (ModelState.IsValid)
{
//Save Changes;
}
}
}
or
public ActionResult Index([Bind(Exclude = nameof(SomeDomainModel.Id))] SomeDomainModel model)