filmov
tv
Attribute routing in ASP NET Web API 2
![preview_player](https://i.ytimg.com/vi/jvnQavMzfe4/sddefault.jpg)
Показать описание
For the example code used in the demo, please refer to the text article of this video.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
All ASP .NET Web API Text Articles and Slides
All ASP .NET Web API Videos
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
In this video we will discuss Attribute Routing introduced in ASP.NET Web API 2. Let us understand attribute routing with an example
What is Attribute Routing
Using the [Route] attribute to define routes is called Attribute Routing
What are the advantages of using Attribute Routing
Attribute routing gives us more control over the URIs than convention-based routing. Creating URI patterns like hierarchies of resources (For example, students have courses, Departments have employees) is very difficult with convention-based routing. With attribute routing all you have to do is use the [Route] attribute as shown below.
[Route("api/students/{id}/courses")]
How to enable Attribute Routing
config.MapHttpAttributeRoutes();
Can we use both Attribute Routing and Convention-based routing in a single Web API project
Yes, both the routing mechanisms can be combined in a single Web API project. The controller action methods that have the [Route] attribute uses Attribute Routing, and the others without [Route] attribute uses Convention-based routing.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
All ASP .NET Web API Text Articles and Slides
All ASP .NET Web API Videos
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
In this video we will discuss Attribute Routing introduced in ASP.NET Web API 2. Let us understand attribute routing with an example
What is Attribute Routing
Using the [Route] attribute to define routes is called Attribute Routing
What are the advantages of using Attribute Routing
Attribute routing gives us more control over the URIs than convention-based routing. Creating URI patterns like hierarchies of resources (For example, students have courses, Departments have employees) is very difficult with convention-based routing. With attribute routing all you have to do is use the [Route] attribute as shown below.
[Route("api/students/{id}/courses")]
How to enable Attribute Routing
config.MapHttpAttributeRoutes();
Can we use both Attribute Routing and Convention-based routing in a single Web API project
Yes, both the routing mechanisms can be combined in a single Web API project. The controller action methods that have the [Route] attribute uses Attribute Routing, and the others without [Route] attribute uses Convention-based routing.
Комментарии