"No route in the route table matches the specified values" when using areas

I know that this error appeared to people before, but this seems to be a bit of a special case.

I worked on creating a SPA with ReactJS on top of ASP.NET MVC 4. I had no problems working on my machine. However, the strange problem that I see is that it does not work on other machines for other developers. As far as I saw, I do not have files that are not checked under source control. I used RouteDebugger and I see that the correct route is caught.

The route I use for this SPA is / V 2 / Home. So I have an area called "V2", an MVC in an area called "HomeController", and it has a view called "Index". I am setting up an application in V2AreaRegistration.

public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "V2_default", "V2/{*url}", new { area = "V2", controller = "Home", action = "Index" } ); } 

Here is Application_Start in Global.asax.cs

 protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); AutoMapperConfiguration.Configure(); Logger.Info("Application started"); GlobalConfiguration.Configuration.EnsureInitialized(); } 

It didn’t lead me to anything. I would like this to be resolved. Feel free to ask for something to skip.

+7
asp.net-mvc asp.net-mvc-4 asp.net-mvc-routing asp.net-mvc-areas
source share
2 answers

I'm not sure what it is, but I managed to fix my problem. This has something to do with the way we handle routing and authentication / permissions.

+2
source share

I cannot explain how this will work on your computer, but not on the computers of your colleagues.

It looks like your zone registration does not know what namespace your controllers are in. Try adding the 4th argument to the MapRoute method call declaring the namespace of your new controllers:

 public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "V2_default", "V2/{*url}", new { area = "V2", controller = "Home", action = "Index" }, new string[] { "MyApplication.MyMvcProject.Areas.Controllers" } // Change this to the namespace of your area controllers. ); } 
+1
source share

All Articles