question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A route named 'swagger_docs' is already in the route collection. Route names must be unique. Parameter name: name

See original GitHub issue

I have a fresh install of Swashbuckle installed. It ran successfully the first time with one API controller defined and then when I added a second controller, it puked this message.

[ArgumentException: A route named 'swagger_docs' is already in the route collection. Route names must be unique.
Parameter name: name]
   System.Web.Routing.RouteCollection.Add(String name, RouteBase item) +3746353
   System.Web.Http.WebHost.Routing.HostedHttpRouteCollection.Add(String name, IHttpRoute route) +107
   System.Web.Http.HttpRouteCollectionExtensions.MapHttpRoute(HttpRouteCollection routes, String name, String routeTemplate, Object defaults, Object constraints, HttpMessageHandler handler) +357
   Swashbuckle.Application.HttpConfigurationExtensions.EnableSwagger(HttpConfiguration httpConfig, String routeTemplate, Action`1 configure) +440
   Swashbuckle.Application.HttpConfigurationExtensions.EnableSwagger(HttpConfiguration httpConfig, Action`1 configure) +63

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:30 (2 by maintainers)

github_iconTop GitHub Comments

30reactions
gabrielbarceloscncommented, Jul 8, 2015

Delete bin/obj folders worked for me.

10reactions
archilcommented, Feb 18, 2017

For me the fix was simple. SwaggerConfig contains this line at the start of file

[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), “Register”)]

So it automatically gets called. But I was calling Register method on demand, the old-fashioned way. Removing manual call solved the case

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why am I getting "A route named 'swagger_docs' is already ...
The error message says "A route named 'swagger_docs' is already in the route collection". How can I fix this? Microsoft Azure Collective. azure ......
Read more >
System.ArgumentException A route named X is already in ...
For more information, check Azure deployment: A route named 'HelpPage_Default' is already in the route collection. Route names must be unique. Parameter name: ......
Read more >
Azure API: A route named 'swagger_docs' is already in the ...
Azure API: A route named 'swagger_docs' is already in the route collection. Route names must be unique.
Read more >
A route named 'HomePage' is already in the ...
A route named 'HomePage' is already in the route collection. Route names must be unique. ... Route names must be unique. Parameter name:...
Read more >
A route named 'swagger_docsswagger/docs/{apiVersion}' ...
I am getting this error when I try to run an existing project that seems to be building and running just fine for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found