Question

Am migrating a WebApi project (from preview version aka WCF WebApi to final release aka ASP.NET MVC4 WebApi).

In WCF WebApi, URI templates were defined for all services operations, like:

[WebGet(UriTemplate = "{movieGenreId}/movies")]

Bare I mind I have tens of those in the project. How do I translate this to MVC4 WebApi without having to register tens of entries in the Route table?

Was it helpful?

Solution

You could go with the excellent attribute routing for Web API project:

It should be almost as easy as search and replace to convert UriTemplates to Attribute Routing.

If you are not willing to include the attribute routing library in your project, unfortunately the only other way is - as you said - registering tens of routes.

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