Learn how you can use attributes to mark up your parameters and make them bind to the request in custom ways.
- [Instructor] At times you may want to make sure…a parameter being sent to your Web API action method…is being bound only from a certain source,…either from the body of the request…or from the URL path.…Web API provides us with two convenient attributes…that we can use to mark up our code for just this reason.…The first one, from body,…looks for the marked parameter only in the request body.…The second, from URI,…looks only in the URI or address.…The other reason you might wanna use from body or from URI…is if you are breaking the parameter binding conventions.…
For instance, you might have a complex…object-type parameter,…and for certain reasons you need to pull its properties…in from the URI and not from the body.…Since Web API defaults complex types…to be coming from the body,…you'd have to use the from URI attribute in this case…to break with that convention.…Looking back at the tour controller methods…we created earlier,…we can mark up the free only boolean parameter…on the get method with a from URI like this,…
AuthorJonathan "J." Tower
- Convention-based routing
- Binding your code to an HTTP request
- Validating models
- Using attributes to route requests
- Customizing attribute routes
- Data serialization and model binding
- Error handling
- Using exception filters and exception loggers
- API documentation and testing
- Securing your API
Skill Level Beginner
ASP.NET MVC: HTTP Request Life Cyclewith Janan Siam2h 15m Advanced
1. Controllers and Actions
3. Data Serialization and Model Binding
4. Error Handling
5. API Documentation and Testing
Next steps1m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.