I'm an experienced .NET developer, making my first steps in .NET Core in the passed few days, more specific in building RESTful APIs using ASP.net Core.
I know there are 2 possible routing options - Convention Routing (traditional) vs the Attribute Based Routing (newer).
I've read that the ASP.net core's development team recommendation is to use Attribute Based Routing for APIs rather than the tradition Convention Based routing, which is more suitable for MVC applications.
I'd really like to understand - Why?
It seems that the attribute based routing makes us write more code ending up having the same behavior as the conventional routing.
Both options are valid. Following are some suggestions on when to use each one. Consider choosing traditional routes when:
Consider choosing attribute routes when:
But the reasons why many developers recommend the Attribute Routes
is because it allows you quite a bit more flexibility and places the routes next to the actions that will actually use them.
You can switch from option to another at any time is not difficult
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With