I need to match th开发者_开发百科is route in my ASP MVC application:
http://localhost/<itemName>/details
When the item name has illegal characters, for example the % symbol, the following URL will blow up:
(1) http://localhost/item%25Name/Details
In this case the correct URL would be:
(2) http://localhost/Details/?item=item%25Name
Is it possible to define routes in RegisterRoutes
to match normal routes to (1), and routes with the % symbol in the item name, to (2)?
Thanks in advance
Here is what I would recommend you:
- For everything that is part of the query string you don't have to worry. It's not necessary to do any special routing.
- For everything that goes into the path part of the url you could filter dangerous characters. Here's how this is done on StackOverflow with question titles in the url for example.
精彩评论