tags:

views:

45

answers:

1

The following MVC route Page/View/Id would go to the View Method in the Page Controller

I would like the following route:

/{page-title}

So could use a route like this: http://www.mysite.com/This-Is-a-Page

How do I configure this, considering This-Is-a-Page might be a controller also?

A: 

You might be able to add a catch all, like so (place this after the default routes):

routes.MapRoute(
    null,
    "{*query}",
    new { controller = "SomeController", action = "SomeAction" }
);

And the action signature would look like this:

public ActionResult(string query)
Mickel
This only works if you define it before the default, if defined after default, it will assume title is a controller
IceHeat
Not if there is no controller for that title. This route catches all that does not match any of the above.
Mickel