I've got a v7 site that exposes an API to support a mobile app. The API is now being versioned to continue support for legacy versions of the app. The problem I seem to be encountering is that once adding v2.0 of the API I start getting errors such as:
A route named '######' is already in the route collection. Route names must be unique.
This is despite me having the route prefix attribute such as [RoutePrefix("api/v2/")] on the controllers. The only way I can get rid of the error is to rename all controllers in the new version which I'd prefer not to have to do.
In case you're wondering, I have enabled attribute routing:
config.MapHttpAttributeRoutes();
My guess is that the issue is caused by the automatic routing in Umbraco but is there any way for that to be prevented in this scenario?
Umbraco 7 Routes Issue with Versioned Web API
I've got a v7 site that exposes an API to support a mobile app. The API is now being versioned to continue support for legacy versions of the app. The problem I seem to be encountering is that once adding v2.0 of the API I start getting errors such as:
This is despite me having the route prefix attribute such as
[RoutePrefix("api/v2/")]
on the controllers. The only way I can get rid of the error is to rename all controllers in the new version which I'd prefer not to have to do.In case you're wondering, I have enabled attribute routing:
My guess is that the issue is caused by the automatic routing in Umbraco but is there any way for that to be prevented in this scenario?
Hi Simon
Shannon had a blog post about how you could do this a while back:
https://shazwazza.com/post/need-to-remove-an-auto-routed-controller-in-umbraco/
I guess it depends on how many you have and whether it's ok to just hardcode their removal, or whether you need to do something cleverer...
Hope it helps anyway.
regards
marc
Thanks Marc, this gives me something to go on.
is working on a reply...