Question

I have an area called "Location" in which there is a controller called "CountryController". I would like to call the GET action using api/location/country. Is there any way to specify Areas in the default route?

Ideally something like

routeTemplate: "api/{area}/{controller}/{action}/{id}"
Était-ce utile?

La solution

You will need to write a custom action selector to achieve selection based on namespaces.

Since it's tough to get right (and get the performance and caching after you do it).

I'd recommend going with attribute routing instead.

Autres conseils

Area functionality not available in Asp.Net Web API project, and its harder to maintain with custom way like Namespace based controller.Please visit https://stackoverflow.com/a/34452395/1365663 to get your solution

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top