Different controllers with the same name in two different scopes cause a routing conflict

I have two areas:

ControlPanel

and Patients

.

Both have a controller called ProblemController, similar only in name. The desired results would be routes that give / controlpanel / problems => MyApp.Areas.ControlPanel.Controllers.ProblemsController and / patient / problems => MyApp.Areas.Patients.Controllers.ProblemsController.

Each has routes configured as follows:

public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "**Area Name Here**_default",
                "**Area Name Here**/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }

      

where ***** Region name here ***** is either the control group or the patient.

When I go to / patients / problems / create (for example), I get 404, where the routing error says A public action method 'create' was not found on controller 'MyApp.Areas.ControlPanel.Controllers.ProblemsController'

.

I'm not sure what I am doing wrong.

+2


a source to share


2 answers


Actually, it turns out that the problem is related to Autofac 2.1 AutofacControllerFactory

. The routes are working correctly, but autofac is having a hard time finding the correct controller.

For those using Autofac and MVC 2.0, Autofac 2.1 does not support scopes. If your project is simple enough, Autofac can handle scopes, but it will start to degrade as your scopes and controllers get more complex.



Area full support ticket has been closed and associated code verified, but from what I can tell, it won't be released until 2.2. I'm going to try and build from a trunk and I'll lecture how it goes.

UPDATE Yes, everything looks good using Autofac built from trunk. Hope 2.2 will be officially released soon.

+1


a source


Have you tried overloading with the namespaces parameter?



ASP.NET MVC 2 Preview 2: Duplicate Area Disks Issue

0


a source







All Articles