I am struggling with routing issues in my ASP.NET MVC + WebAPI app. I feel like I have a moving target here because when I add or change one route I break another. Here is my specific example.
First, my controllers, so you can see the names:
Next, my MVC routing config (I understand that my config is probably duplicative, but it is because I am trying things):
And my Web API routing config (I understand that my config is probably very duplicative, but it is because I am trying things):
As a routing problem example, here's the PodcastFeeds API controller:
So I post to the Create action method...
And as you can see I get the error: 404 not found - "No HTTP resource was found that matches the request URI
.
I would love some direction here...
The order or registering routes is important since requests are handled by the firs route that matches the patter. Because your default route is the first one it always selected. You need to put your default route to be the last one and register all your routes starting from the most constraining and ending with default one. Also Is I see in your screenshots some of your routes are not fully configured: for example
api/PodcastFeeds
route doesn't specify a controller (it needs to look similar to yourFeedRouteMap
route from the second screenshot):As an alternative you can use attribute routing to avoid those kind of issues.