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

1

When I run locally the website runs fine. But when deployed on Microsoft Azure , it is throwing the above error occurs.

I already tried deleting the .DLL Files from bin folder and obj folder, but the problem still exist.

Stack Trace:

[ArgumentException: A route named 'HelpPage_Default' is already in the route collection. Route names must be unique.
Parameter name: name]
   System.Web.Routing.RouteCollection.Add(String name, RouteBase item) +3213863
   System.Web.Mvc.RouteCollectionExtensions.MapRoute(RouteCollection routes, String name, String url, Object defaults, Object constraints, String[] namespaces) +203
   System.Web.Mvc.AreaRegistrationContext.MapRoute(String name, String url, Object defaults, Object constraints, String[] namespaces) +56
   Makewayy.Areas.HelpPage.HelpPageAreaRegistration.RegisterArea(AreaRegistrationContext context) +87
   System.Web.Mvc.AreaRegistration.CreateContextAndRegister(RouteCollection routes, Object state) +104
   System.Web.Mvc.AreaRegistration.RegisterAllAreas(RouteCollection routes, IBuildManager buildManager, Object state) +190
   System.Web.Mvc.AreaRegistration.RegisterAllAreas(Object state) +34
   Makewayy.WebApiApplication.Application_Start() +12

[HttpException (0x80004005): A route named 'HelpPage_Default' is already in the route collection. Route names must be unique.
Parameter name: name]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +10104513
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

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

Route Configuration:-

public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}

AreaRegistration -

namespace Makewayy.Areas.HelpPage
{
    public class HelpPageAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "HelpPage";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "HelpPage_Default",
                "Help/{action}/{apiId}",
                new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });

            HelpPageConfig.Register(GlobalConfiguration.Configuration);
        }
    }
}
c#
asp.net-mvc
asp.net-mvc-4
azure-web-app-service
asked on Stack Overflow Nov 14, 2017 by Rachit Rastogi • edited Oct 17, 2018 by d219

4 Answers

3

A route named 'HelpPage_Default' is already in the route collection. Route names must be unique.

Per my understanding, you need to make sure that you have not defined the route named HelpPage_Default no more than once. Also, you need to check your code and make sure that AreaRegistration.RegisterAllAreas(); could only be called once.

Moreover, please make sure your application could work on your local side. And before publishing it to azure website, you could use kudu and empty the web content under D:\home\site\wwwroot, then redeploy your application.

answered on Stack Overflow Nov 15, 2017 by Bruce Chen
1

Specifically for deploying to Azure after renaming files the accepted answer here is likely the answer. All worked fine when I deployed locally, and cleaning/deleting bin folder did nothing, what did work was.

  1. On the Visual Studio publish screen click Configure
  2. From the new Window click the vertical Settings tab
  3. Expand File Publish Options
  4. Tick the 'Remove additional files at destination' checkbox.

enter image description here

answered on Stack Overflow Oct 17, 2018 by d219
0

If cleaning your bin folder still doesn't help, maybe it's because you have accidentally added a reference to another API of your solution in your project (which would register route config of both APIs -> Ouch!).

answered on Stack Overflow Nov 19, 2019 by evannah
0

I encountered this error after I renamed my project, renamed the folder structure and altered the .sln file to reflect these changes. I tried cleaning the solution but that didn't work for me. I had to delete the contents of the bin folder and then I got past the error.

answered on Stack Overflow Mar 31, 2021 by Dan Leksell

User contributions licensed under CC BY-SA 3.0