سؤال

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}"
هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top