BKStart a conversation ↗

MVC Binding restriction

There are a few options when restricting what properties of a type get automatically bound by the framework.

Take the Loler type seen in my other MVC2 blog posts.

[Bind(Include="ID,Name,Description")]
public class Loler
{
//entity framework generated
}

Notice only the ID, Name and Description properties will be bound by the MVC Framework.

Per Usage restriction

UpdateModel(loler, new[] { "ID", "Name", "Description" });

Action method restrictions

[HttpPost]
ActionResult Create([Bind(Include="ID,Name,Description")] Loler loler)
{
// implementation
}