Attribute routing in ASP NET Web API 2

preview_player
Показать описание
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.
Рекомендации по теме
Комментарии
Автор

Thank you so much. Your final comment regarding adding the config.MapAttributeRoutes(); in the WebApiConfig.cs saved me from going in sane. No idea why I missed this in the first place. Very clear and concise tutorials. Keep up the good work.

dazzam
Автор

Super, your teaching skill with example is awesome.

NavinKumar-xrjn
Автор

Thank you! I'm looking forward to watching your newer API videos for AspNet Core & Blazor.

belmiris
Автор

Thanks for the video teaching on REST API routing.

felterhills
Автор

This series has been extremely helpful for me learning c#! Thank you for taking the time to create such good content!

Adam-pljj
Автор

Again one word "Great Job" ..

lonelylov
Автор

Thankuuuu... very much sir. This article is very

noorjahan
Автор

Hello Mr. Venkat. You are asking me to have a great day, but it's evening here. Hehe. Just kidding. Nice tutorial.

BigyanChap
Автор

Sir, your videos are awsome... i m new to .net and i m learning .net from your mvc tutorials and web api tutorials... but please sir also make vido on web api with rest concept.... and sir please make videos on xamarin mobile app development...

himeshnagar
Автор

Attribute routing was introduced in mvc 5 right??

akhilnambiar
Автор

sir, please upload video of web api with rest concept.

shazOfficialTech
Автор

sir, is there any way to maintain state of data in webapi, just like asp.net have state management technology.

sarveshsingh-twch
Автор

Sir,
Would you please discuss external authentication providers like Twitter, Microsoft?Thanks

sovanroy
Автор

Thank u, for your great videos.
I am facing an issue,
i hav a controller which has multiple post actions but an unable to call them due to 'Multiple actions were found that match the request' error.
Could you help me with this please?

divyatnair
Автор

Please make a video for how route if multiple routes having same name, different folders in web api

bonagiribhargavi
Автор

Sir if possible show paypal Api integration also.

jeewanintube
Автор

How to create public authorisation for API

ravivishwakarma
Автор

how to call web api from angular js client ?

anishtaneja