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?

asked Oct 29, 2012 at 12:54
2
  • Can't you just rename your files with - instead of spaces? Commented Oct 29, 2012 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. Commented Oct 29, 2012 at 13:10

1 Answer 1

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.

answered Oct 29, 2012 at 12:56
Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.