Skip to content

The same web api controller name in 2 different areas, name spaces, and route prefixes cancel each other out with no warning or error #172

@mikewodarczyk

Description

@mikewodarczyk

My asp.net site is split into areas with different overrides of AreaRegistration, Each area is its own business context and could have different developers. I happened to chose a name for a web api controller eg. CustomerApiController (inheriting from ApiController) in one area (Shipping). This same web api controller name was used in another namespace (SalesOrder). They had separate [RoutePrefix("...")], existed in a different name space, linked to a different database under the covers, and meant something different.

The problem is that neither of them worked after I added the second one. The produced a "not found" when the client called into the APIs.

It looks like at the controller discovery phase, they are thrown out and not included in routing. I didn't
get any static analysis warnings from visual studio 2017 (latest version). I didn't see any exceptions or errors from the routing engine. It seems like this case should either be handled correctly by including names spaces or route info in the controller name descriptor, or it should fail loudly with some relevant exception,

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions