Cascading MVC controllers with CatchAll Routes
- by Richard
Hi,
I have an MVC app which has its routes defined with the final route being a catch all route to a "PageController" for a database driven collection of pages. What I want to achieve is to be able to plugin to the app a second controller to the catch all route which the first controller passes on to if it does not find the url recieved in the database.
Effectively I want to queue up controllers with catch all actions:
public ActionResult PageCatchall(string url)
{
var page = repository.Get<Page>(string url);
if (page != null)
{
// Handle the request
return View(page)
}
// Otherwise pass to a new controller
????
}
Anyone have any good ideas as to how to solve this? I have tried RedirectToAction but that requires that the next controller has a different route to the action. I have tried ActionInvoker but this failed to work the way I did it.