0

i have a similar question to [A route named x is already in the route collection][1] [1]: A route named x is already in the route collection. Route names must be unique. But the solution mentioned there doesn't worked for me. In my solution (for Sitecore 9.0.1), i just added an Api Controller for PoC and deleted later again, and since then i'm not able to run Sitecore. Consider, that i don't have a Global.asax file or App_start Folder.

Could some one help me? I will appreciate it. Thanks.

Best Regards

+++++++++++ Displayed Error +++++++++++

Server Error in '/' Application. A route named 'MS_attributerouteWebApi' is already in the route collection. Route names must be unique. Parameter name: name Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: A route named 'MS_attributerouteWebApi' is already in the route collection. Route names must be unique. Parameter name: name

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: A route named 'MS_attributerouteWebApi' is already in the route collection. Route names must be unique. Parameter name: name] System.Web.Routing.RouteCollection.Add(String name, RouteBase item) +391
System.Web.Http.Routing.AttributeRoutingMapper.MapAttributeRoutes(HttpConfiguration configuration, IInlineConstraintResolver constraintResolver, IDirectRouteProvider directRouteProvider) +166
Sitecore.Services.Infrastructure.Web.Http.HttpConfigurationBuilder.MapHttpAttributeRoutes() +89 Sitecore.Services.Infrastructure.Web.Http.ServicesConfigurator.Configure(HttpConfiguration config, RouteCollection routes) +501
Sitecore.Services.Infrastructure.Sitecore.Pipelines.ServicesWebApiInitializer.Process(PipelineArgs args) +194 (Object , Object[] ) +74
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +469
Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
Sitecore.Nexus.Web.HttpModule.Application_Start() +161
Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app) +764
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +581
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +418
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

[HttpException (0x80004005): A route named 'MS_attributerouteWebApi' is already in the route collection. Route names must be unique. Parameter name: name]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +534
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +718

3
  • Don't you have still dll that you added custom routes previously in in your bin folder and still therefore applied even though you have removed code? Check bin folder. Maybe also some old config left and not deleted could cause this problem. I don't know how you added your previous routing as it is neither specified here nor in previous question. Check also /sitecore/admin/showconfig.aspx whether you can find 'MS_attributerouteWebApi' there. Jun 3 '18 at 18:27
  • @PeterProchazka I think that he would not be able to see showconfig.aspx because adding routes fails on app start, so application even can't start. But, in general, I agree, somewhere is names duplication.
    – Anton
    Jun 4 '18 at 8:51
  • Hi Peter, actually i was not able to call showconfig.aspx, but you have right, the bin folder has old dll. I deleted the old dll's and it works. Thank for the hint.
    – Najem
    Jun 4 '18 at 20:40
0

To resolve this issue:

  • Take a look whether you still have old dlls that you added custom routes with previously in your bin folder. If they are there, they are still therefore applied even though you have removed code. You need to remove them.
  • Check also whether you have some old config files under App_Config folder left and not deleted. They could be also still applied. They need to be removed.
2
  • If the original answer can be expanded upon, that's where this information should go. Alternatively post an additional answer to the original question. We should try and avoid having multiple questions with almost identical titles and content.
    – Mark Cassidy
    Jun 5 '18 at 15:55
  • 1
    @MarkCassidy Make sense. I have added answer to original question also. Jun 5 '18 at 16:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.