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.

3
  • did you try to html.encode the querystring before sending? Commented Nov 23, 2009 at 13:15
  • actually the request will come from an iPhone app, i don't have control of encoding the url before sending it! Commented Nov 23, 2009 at 14:19
  • then use encodeURIComponent to encode it with javascript Commented Nov 23, 2009 at 16:43

2 Answers 2

1

See this question URL-encoded slash in URL.

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

I already have a catch-all route set to something else. I can't have more than one catch-all routes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.