Unable to get ASP.NET MVC and Web API routing straight in my mind - getting 404s galore -
i struggling routing issues in asp.net mvc + webapi app. feel have moving target here because when add or change 1 route break another. here specific example.
first, controllers, can see names:
next, mvc routing config (i understand config duplicative, because trying things):
and web api routing config (i understand config duplicative, because trying things):
as routing problem example, here's podcastfeeds api controller:
so post create action method...
and can see error: 404 not found - "no http resource found matches request uri
.
i love direction here...
the order or registering routes important since requests handled firs route matches patter. because default route first 1 selected. you need put default route last 1 , register routes starting constraining , ending default one. see in screenshots of routes not configured: example api/podcastfeeds
route doesn't specify controller (it needs similar feedroutemap
route second screenshot):
routes.maphttproute( name: "podcastfeeds", url: "api/podcastfeeds/{action}/{id}", defaults: new {controller="podcastfeeds", action="create", id=urlparameter.optional})
as alternative can use attribute routing avoid kind of issues.
Comments
Post a Comment