views:

212

answers:

1

Hi,

I've an interesting problem with some routing with an ASP.NET MVC app. I'm building a CMS and I've got a catch-all handler that takes the URL and checks to see if there's some matching content in a database. If so, it displays it, otherwise we get a 404.

Now I've got all that working with some test data, I moved on to write a quick admin system. I thought I'd use some of the new Area functionality baked into MVC 2, so I've created an area called Admin with a controller called Home. Now however I have a problem of the default HomeController in the Admin Area is being returned when requesting the application root path.

The problem is that there is no other HomeController for the 'root' application (the one hosting all of the areas), instead the root would be redirected to the my catch-all handler and populated from the database. So now the controller factory is returning the best matching controller, which it thinks is the admin area one, what I really need is for it to not match it at all - as it did previously.

Apart from renaming the Admin HomeController to something else, is there another solution?

A: 

Edit... (sorry last answer was off topic).

Shot in the dark. Try changing the default maproute....

routes.MapRoute( "Default",
"{controller}/{action}/{id}",
new { controller = "Home", area="", action = "Index", id = "" }

or maybe area = null.

or changing the controller from home to something else.

Mark Kitz
Not quiet what's going on, when I request http://localhost/ it will attempt to load the controller at http://localhost/Area/ because that's the ONLY HomeController instance available.
Kieron
I editted my answer above.
Mark Kitz
you may also want to add the namespace option to your default route declaration.
Ahmad