mercredi 6 mai 2015

Manipulate the url using routing

In my website i have the following route defined:

routes.MapRoute(
   name: "Specific Product",
   url: "product/{id}",
   defaults: new { controller = "", action = "Index", id = UrlParameter.Optional }
);

in that way i want customers to be able to add the id of the product and get to the product page.

SEO advisors have said that it would be better if we could add a description of the product on the url, like product name or something. So the url should look like something like:

/product/my-cool-product-name/123

or

/product/my-cool-product-name-123

Of course the description is stored in the db and i cannot do that with a url rewrite (or can i?)

Should i add a redirection on my controller (this would seem to do the job, but it just doesn't feel right)

Aucun commentaire:

Enregistrer un commentaire