lloydphillips
lloydphillips

Reputation: 2855

MVC Routing for categories with spaces

I have a website that has categories for the products. I wanted to have the categories defined in a route pretty much like www.domain.com/categoryA.

Here's my problem what if I have category in my database that is 'Boxing Gloves' how do I handle the space in the category name?

Upvotes: 2

Views: 1126

Answers (1)

Jim Mitchener
Jim Mitchener

Reputation: 9003

You can have spaces encoded as %20, but that doesn't really make for pretty urls. I'd suggest you convert them to dashes and disallow dashes in category names. You could also disable spaces and force users to use dashes like most tagging systems.

Upvotes: 3

Related Questions