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}"
Was it helpful?

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top