I'm having an issue with routing and areas as the title says. I have ana areas section in my project that just has one area in it. It has a Policy controller in there. Outside in the project there is a controller's folder with a LoginController.
When I try to got to the URL "BoB/Login/ChangeSection" (BoB is project name, Login is controller, ChangeSection is action) it gets sent to "BoB/Policy/Login". This means the Area registration inside the Policy area is grabbing the request and putting the Policy prefix in front when it shouldn't be.
Here is my project RouteConfig
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "BoBHome", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "BoB.Controllers" }
);
and here is the Area registration
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
name: "BoBPolicy_default",
url: "Policy/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "BoB.Areas.BoBPolicy.Controllers" }
);
}
I was under the impression the namespaces would keep this from happening, but it obviously is not. Any help is appreciated.
Some additional info:
This comes from another project that is not MVC so the Redirect looks like this:
Response.Redirect("/BoB/BoBLogin/ChangeSection?controller=PolicyOverview");