Get an overview of attributes that allow you to bind your controller methods to specific HTTP verbs.
- Now I didn't love the way…that we named the post search method…in the tour controller earlier.…So, let's revisit that.…Looking at the code you'll recall that we were forced…to start the method name for…the post search method here on line 25.…With the word post because we wanted it…to respond to the http post,…request.…Ideally I prefer this method name to be more readable…and to clearly state what it actually does.…Thankfully web API gives us a mechanism…to do just that.…
To target a specific http verb.…For a method without having to use that…in the name of the method.…We can accomplish this using…the attributes we've listed here.…All starting with http and ending with the verb…that they represent.…Back in the tour controller,…let's update our post method to use the http post attribute.…First I'm gonna rename the method…to something that I think is a little more meaningful.…Instead of post search let's call it,…search tours.…
I think that more accurately captures…what it's actually going to do.…Then let's mark this method with the http post attribute.…
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.