2

I'm trying to route to the home page of an Area in MVC, e.g.

myDomain.com/myArea/Home/Index

when I use the URL:

myDomain.com/myArea

MVC appears to by trying to find a Controller called "myArea" in the root Controllers folder and thereby would route to:

myDomain.com/myArea/Index

if the Controller existed.

Again, I want:

myDomain.com/myArea

to route to:

myDomain.com/myArea/Home/Index

I figure that I should be able to do this in Global.asax without having to resort to creating a dummy controller that re-routes to the area controller, but I've drawn a blank.

Jason Berkan
  • 8,734
  • 7
  • 29
  • 39
Oundless
  • 5,425
  • 4
  • 31
  • 33

1 Answers1

0

One way I used to get around this was to set the namespaces property on the default route in the Global RegisterRoutes method, this seemed to resolve that problem. Had to add this restriction to some other routes where I had conflicts between Controller in the main website and the area.

var namespaces = new[] { "CompiledExperience.Website.Web.Controllers" };

routes.MapRoute("Default", "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    namespaces
);
Nigel Sampson
  • 10,549
  • 1
  • 28
  • 31
  • Yes, I already tried that, but it made no difference. I made sure I restarted IIS to ensure that the routes were re-registered. Thanks though. – Oundless Oct 29 '10 at 08:55
  • MooseFactory did you figure this one out?. i have the same issue – ShaneKm Dec 01 '11 at 11:37