I am facing a problem that one of my fields need to be shown in the url contains special character (/, \, :).
The stupid way to handle this generate action links by using UrlEncode(). Then UrlDecode is used before consuming in controller. But I think it really stupid because too many places need to be adapted.
So, my problem is there any way to extend the url route or jus开发者_如何学Ct write my own one to achieve it?
Thanks, Mike
You can extend the System.Web.Routing.Route
object to create a custom route and override the GetRouteData
and GetVirtualPath
methods. These are called to resolve a route's values and create a URL from given route values, respectively. However, I don't think URLs can contain URL encoded values for / (%2f) within the path portion of a URL though it is ok in a query string.
精彩评论