The action parameter in ASP. NET MVC is not just some basic type, it also supports entity parameters. So how does the data from the client map or convert to entity objects? is through the entity binding class Modelbinder. This family of classes captures the data passed in and parses and transforms it to the entity class object before requesting the action method to convert to a background controller.
Before the system starts, the method Application_Start method in Global.asax.cs calls the following code to define the parameter conversion rules.
[CSharp]View PlainCopy
- Model Binders
- ModelBinders.Binders.Add (typeof (Basenopmodel), new Nopmodelbinder ());
Nopmodelbinder inherits the system's entity binding class, but it seems to only leave an excuse and is not used by Defaultmodelbinder. The main way to inherit the parent class, slightly changed is: Method Bindmodel added support for Nopmodel binding.
[CSharp]View PlainCopy
- Public override object Bindmodel (ControllerContext controllercontext, Modelbindingcontext BindingContext)
- {
- var model = base. Bindmodel (ControllerContext, BindingContext);
- if (model is Basenopmodel) ((Basenopmodel) model). Bindmodel (ControllerContext, BindingContext);
- return model;
- }
Method Getmodelproperties adds a filtering method, except that this method is not yet enabled.
Class Basenopmodel is the base class for all model and supports storage of custom properties. And there is a method that binds to the parser, Bindmodel, but has not yet found a subclass to implement this method.
Nopcommerce Five-------model binding Action parameter