[BindProperties] Attribute | Bind Properties Model Binder | ASP.NET Core 5.0 Web API Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
the second attribute is bind properties bind properties is also an attribute and it is used to map the incoming form data to the public properties of the controller the binding concept of the bind property attribute and the bind properties attribute is same bind properties work on simple and complex objects by default the bind properties does not work for http get request point properties is applied on the controller level this is the only difference in between bind property and the bind properties we are using the bind property individually on all the properties that we have defined in the controller file but if you are using the bind properties then you can use this attribute at the controller level and there is no need to define the bind property on each property individually let's see how it works let's remove this bind property from here and let's comment this country property open the country model and let's copy all three properties paste them over here update the code from here and this time instead of using the bind property we will be using bind properties the bind properties works on the controller level so here you can use the point properties and there is no need to define any attribute at the property level that's it let's build this application build is successful let's run the application in debug mode let's put a breakpoint over here and open the postman send the same request again let's see what we got in the property we are getting null because by default the bind properties also not works with the get request so first we can start with the http post run the application again open the postman and here let's use the post method hit the send button let's see what we got in the properties we are having the values in the name the population and the area this is how we can use this bind properties attribute at the controller level to bind all the properties of this controller click on the continue button and here is the output this code will also work with the complex type property so if we enable this one and comment all these properties update the code over here let's run this application again send the request by clicking on the send button and let's see what we got in this country property here we got all three properties that we are sending in the request click on the continue button to enable the support of the http get request we need to set the supports get property to true to view the details we can right click on this one and choose go to definition and here is the property supports cat if you are passing through in the supports get then the data binding will work for the get request also and this time let's make it http get run this application again in debug mode from the postman let's use the get method and hit the send button here we go to the debugger and let's see what data we got in this country property we have everything that we are sending in our http request this is how you can use the bind properties at the control level to bind all the properties of your controller file
Info
Channel: WebGentle
Views: 17,032
Rating: undefined out of 5
Keywords: asp.net core web api, web api asp.net core 5, web api asp.net core, .net 5 web api, api in .net core 5.0, asp.net core web api tutorial, asp.net web api core 5, Restful web api asp.net core, how to build restful apis with asp.net core 5, how to build restful apis with asp.net core, asp.net core, asp.net core web api tutorial for beginners, restful web api tutorial asp.net core, asp.net core web api tutorial webgentle, asp.net core web api tutorial nitish
Id: LIEm1EPw2dg
Channel Id: undefined
Length: 3min 35sec (215 seconds)
Published: Fri Apr 09 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.