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);
}
}
}
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.
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.
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!).
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.
User contributions licensed under CC BY-SA 3.0