Query string with slashes "/" not working in asp.net mvc?
I have a special case here:
My action method accepts one parameter, this parameter is expected to be a full url (e.g. http://www.somesite.com/article/onesite?hello=whatever&etc=blah). When working with old asp.net (oh, excuse me guys, I mean web forms) this works just fine, but when using asp.net mvc and preparing the re开发者_StackOverflowquired route ("/myaction/{inputUrl" with no constraints on inputUrl) it fails. If the url has any slashes I get an "Bad Request" exception. What should I do? Should I add a regex constraint on the passed in url to match a web url? What do you think dear SO Gus?PS: The resource will be requested from an iPhone app, which means, I don't have any control over the coming url (i.e. I can't encode it!)
Thanks in advance.
See this question URL-encoded slash in URL.
Even UrlEncode will not help here. The behaviour changes in MVC2.
Modify your route as /myaction/{*inputURL*}
. This will catch all after myaction.
精彩评论