0

Possible Duplicate:
How does StackOverflow generate its SEO-friendly URLs?

I have an MVC3 site for which I would like to clean up the urls that contain spaces in the names of the products.

Currently, the url displays as: /products/some%20ugly%20url

I would like to display: /products/some-clean-url

Is it possible with MVC3 routing to rewrite the ugly url to the clean one?

Community
  • 1
  • 1
shuniar
  • 2,592
  • 6
  • 31
  • 38
  • Can't you just rename your files with - instead of spaces? – Rob Oct 29 '12 at 12:55
  • Unfortunately no because it relies on another service that requires the spaces. I suppose I could do the rewrite before the service call though instead. – shuniar Oct 29 '12 at 13:10

1 Answers1

2

Short answer: yes this is possible. Just look up. StackExchange runs on ASP.NET MVC.

Try creating a product slug. A slug is a unique string that identifies your item that you want to fetch.

/products/fake-blood
/products/spiders-webs
/products/vampire-teeth

You can then key off the slug, instead of an ID. Many solutions store the slug in the database.

Jarrett Meyer
  • 19,333
  • 6
  • 58
  • 52
  • Thanks, this is a possible solution. I guess I worded my question poorly, I know that its possible, I was wondering whether it was possible natively through routing. – shuniar Oct 29 '12 at 13:09