Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Simon Dingley 1447 posts 3377 karma points c-trib
    Jan 05, 2022 @ 13:14
    Simon Dingley

    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:

    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:


    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?

  • Marc Goodson 1718 posts 11412 karma points MVP 7x c-trib
    Jan 12, 2022 @ 10:32
    Marc Goodson

    Hi Simon

    Shannon had a blog post about how you could do this a while back:

    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.



  • Simon Dingley 1447 posts 3377 karma points c-trib
    Jan 17, 2022 @ 12:02
    Simon Dingley

    Thanks Marc, this gives me something to go on.

Please Sign in or register to post replies

Write your reply to: