0
votes

So, I would really like to create "landing page" routes for each of a particular type of entity.

So, let's suppose I have a site that is about comic heroes.

I would like landing pages like http://myherosite.com/superman and http://myherosite.com/batman, etc.

I know how to accomplish this with something like http://myherosite.com/heroes/superman and http://mysite.com/heroes/batman. The "heroes" in the URL allow for a specific route and thus controller and default action.

Is it possible to setup a route that will accomplish this and still leave the default route ("{controller}/{action}/{id}") in place (I am using that).

Thanks

1
its hard to understand what you're looking for. you need to explain in greater detail and give multiple examples.Dave Alperovich

1 Answers

0
votes

You could add a route before "Default" that interprets all single-segment paths as containing an action method of the heroes controller.

routes.MapRoute(
    name: "Landings",
    url: "{action}",
    defaults: new { controller = "Heroes" }
);

Of course, that would prevent you from using any default action for the default route because those are single segments paths as well.