views:

59

answers:

2

Hi,

So I have added this route to my map:

    routes.MapRoute(
        "Default", 
        "/Bikes/{id}", 
        new { controller = "Bike", action = "Detail" }
    );

But for SEO reasons we need to have urls like: /bikes/54/name-of-bike/kind-of-bike/number-of-wheels ... etc etc. But everything after id (54) can be ignored.

Does anyone know how to create such a MapRoute to allow that, the route above does not work actually for urls that contain stuff after the id.

Thanks

--MB

+1  A: 

Something like this

routes.MapRoute(
    "Default", 
    "/Bikes/{id}/{slug*}", 
    new { controller = "Bike", action = "Detail", 
          slug = UrlParameter.Optional}
);
gandjustas
You need to use `{*slug}` as yours isn't valid
BuildStarted
+2  A: 

You can use a catchall parameter like so

routes.MapRoute(
    "Default", 
    "/Bikes/{id}/{*stuff}", 
    new { controller = "Bike", action = "Detail", stuff = UrlParameter.Optional }
);

then anything after id will be stored in stuff

BuildStarted