2

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 required 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.

Ahmed
  • 11,063
  • 16
  • 55
  • 67

2 Answers2

1

See this question URL-encoded slash in URL.

Even UrlEncode will not help here. The behaviour changes in MVC2.

Community
  • 1
  • 1
Mathias F
  • 15,906
  • 22
  • 89
  • 159
0

Modify your route as /myaction/{*inputURL*}. This will catch all after myaction.

Christian13467
  • 5,324
  • 31
  • 34
  • I already have a catch-all route set to something else. I can't have more than one catch-all routes. – Ahmed Nov 24 '09 at 09:46