Learn how to use attributes to route requests to your controller methods in place of the routing table.
- [Instructor] We've seen how Web…API allows us to create complex,…robust routes with our routing table.…But if you're like me, the routing table…may have left you wishing for something…a little bit more direct, simple and obvious.…Well, never fear, because Web API…has another option for routing…and it's called Attribute Routing.…We've used attributes already to bind…certain http verbs to our action methods,…but let's learn how to use similar attributes…to do the same thing for our route paths.…
Before we start adding route attributes…to our action methods, though,…we need to tell Web API that we'd…like it to look for Attribute Routing.…We can do this in the startup class,…where we configure the rest of Web API right here…before we actually start creating our routes,…and we'll tell it we want to configure…and use the Map Http Attribute Routes method.…Now, Web API will look for the attributes…that we're about to start adding.…Previously, in the Tour controller,…we created a couple of additional Get methods.…
On line 26, the Get by ID and on line 36 the Get by name.…
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.