Nopcommerce Five-------model binding Action parameter

Source: Internet
Author: User
Tags nopcommerce

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
    1. Model Binders
    2. 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
  1. Public override object Bindmodel (ControllerContext controllercontext, Modelbindingcontext BindingContext)
  2. {
  3. var model = base.  Bindmodel (ControllerContext, BindingContext);
  4. if (model is Basenopmodel) ((Basenopmodel) model).  Bindmodel (ControllerContext, BindingContext);
  5. return model;
  6. }


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.