Types of Model Binding in MVC

Default Binding:

The default binder uses convention-based logic to match the names of posted values to parameter names in the controller’s method. The DefaultModelBinder class knows how to deal with primitive and complex binding as well as collections and dictionaries.
ASP.NET MVC uses a built-in binder object that corresponds to the [csharp]DefaultModelBinder[/csharp] class. The model binder is a class that implements the IModelBinder interface.

Example:

public interface IModelBinder
{
Object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext);
}

Primitive Binding:

The key fact about model binding is that it lets you focus exclusively on the data you want the controller method to receive. You completely ignore the details of how you retrieve that data, whether it comes from the query string or the route.
Suppose that you need a controller method to repeat a particular string a given number of times.
Example:

public class BindingController : Controller
{
public ActionResult Repeat(String text, Int32 number)
{
var model = new RepeatViewModel {Number = number, Text = text};
return View(model);
}
}

Complex Binding:

There’s no limitation regarding the number of parameters you can list on a method’s signature. However,
a container class is often better than a long list of individual parameters.

Example:

public class ComplexController : Controller
{
public ActionResult Repeat(RepeatText inputModel)
{
var model = new RepeatViewModel
{
Title = "Repeating text",
Text = inputModel.Text,
Number = inputModel.Number
};
return View(model);
}
}

Bind Attribute:

The Bind attribute comes with three properties.

Properties of Bind Attribute:

Prefix: It indicates the prefix that must be found in the name of the posted value for the binder to resolve it. The default value is the empty string.

Exclude: It gets or sets a comma-delimited list of property names for which binding is not allowed.

Include: It gets or sets a comma-delimited list of property names for which binding is permitted.

Custom Binding:

To create a custom binder from scratch, you implement the IModelBinder interface.

Example:

public RepeatTextModelBinder : DefaultModelBinder
{
protected override object CreateModel(
ControllerContext controllerContext,
ModelBindingContext bindingContext,
Type modelType)
{
...
return new RepeatText( ... );
}
}