ASP.NET MVC, areas, routing and a controller factory.
Posted
by Kieron
on Stack Overflow
See other posts from Stack Overflow
or by Kieron
Published on 2010-04-05T10:07:24Z
Indexed on
2010/04/05
10:13 UTC
Read the original article
Hit count: 471
asp.net-mvc-2
|asp.net-mvc-routing
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?
© Stack Overflow or respective owner