MVC Routing for categories with spaces

ε祈祈猫儿з 提交于 2019-12-24 03:50:53

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/2082684/mvc-routing-for-categories-with-spaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!