I'm using asp.net mvc3
I have a URL pattern like http://mysite.com/product/{id}
Everything is fine if I use a simple id however our ids are URIs and that causes a problem.
Even 开发者_开发百科when I encode the id using HttpUtility.UrlEncode MVC gives me the following error:
A potentially dangerous Request.Path value was detected from the client (:).
How can I make it work without simply disabling this check for everything? And why an encoded uri is dangerous in the url anyway?
thanks
One approach would be to implement your own RequestValidator and use it with your application.
The below link also has an example http://msdn.microsoft.com/en-us/library/system.web.util.requestvalidator.aspx
Edit:
Apparently there is a way to specify what characters are invalid - http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.requestpathinvalidcharacters.aspx. Setting the list to blank apparently would do the trick. I haven't really tried this one.
精彩评论