Learn how you can customize your routes with constraints and route prefixes.
- [Instructor] Now that we've learned how to use attributes…for our routing, instead of the routing table, let's look…at ways we can customize those routes even further.…The first way we might want to customize…our attribute routes, is with a consistent route prefix…for all the methods in a controller.…In other words, making all of the routes in a controller…start with the same string.…In the tour controller, the prefix we've been using…is api/tour but instead of repeating that prefix…over and over for each attribute route,…we can specify that prefix just once…in a route prefix attribute on a controller class.…
Let's add that now,…and we'll add it with api/tour…and with that RoutePrefix in place,…all of the action methods in this controller…should now start with the path api/tour.…But before we use it, let's remove api/tour…from the other methods that already have it.…Sometimes, you want to apply a RoutePrefix…on every method in a controller except for one or two.…
You can escape from the RoutePrefix by using a tilde…
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.