c# - Does Attribute Routing with Conventional mapped routes make sense -
we have many web api solution 2 projects. 1 project sets web api config stuff , other project contains controllers.
each web api config setup this:
config.maphttpattributeroutes(); config.routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{id}", defaults: new { id = routeparameter.optional } );
as use route/prefix-attributes on every controller/action asked myself config.routes.maphttproute method call still take effect?
actually annotate route attribute on controller @ least overwrite convention behavior of web api. method call obsolete.
is correct? or there still consider, because want remove method call in every project.
the convention-based route still applied. attribute-based routes take precedence (because configured first) if action method has both matching attribute routes and conventional routes, both routes map action in question.
if want use exclusively attribute-based routing, removing convention-based route mapping wise move in order prevent unexpected behaviour (i.e. exposing actions under unintended routes).
of course, want sure you're not inadvertently relying on convention-based routing anywhere first!
Comments
Post a Comment