ASP.NET Core MVC 2.x comprehensive tutorial _ASP.NET Core MVC 20. Model Binding

Model Binding





This is the most simple binding

start looking form. And then find the route from the value, and finally to the Get QueryString


acquired property of this type is filled by reflection. There are several attributes reflective finish, I started to look forward to the value of several properties and bind

Complex type

And finally added a property, which is another object

View page, as long as the front-end is also the object attribute word on it.

Using these Attributes may change or affect the binding

Bind: selectively binding
BindNever: it can be placed on the model attribute. Representation should not be bound
BindRequired: there must be binding

test:
Reception added Role.RoleName

foreground enter the name of the role

extreme look Role.RoleName main point of this value. RoleName binding on the value. Description nested property is bound

and built a ViewModel. Both the above model attribute names and attribute names repeated class

but it is present as a nested property

View properties which are nested manner



is also possible to obtain the value of


the Bind [] represents selective binding



herein may write more attribute value of

the parameter type is the type of params


userName attribute will not be bound

Look at a resume example



Key here is to draw the line







type of action if the model replaced




Source specified Bingding


改变来源的优先级
指定数据的来源






浏览器里面Header的值





 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/10937185.html