tags:

views:

3303

answers:

2

I'm trying to pass u url as parameter to a get method. I defined a route that accepts a {*url} parameter so I can send "/" characters without it separating my parameter. As soon as there is a ":" in the url (like in http: or localhost:3857 for example), the method never gets hit.

The Html.ActionLink method escapes it's parameter itself, but it doesn't seem to escape the ':'. I cannot escape it manually because then the escape characters get escaped by the very same Html.Actionlink method.

any ideas?

+3  A: 

Use EncodeUrl before you pass it, and then decode it on the other side.

Kieveli
I don't know about any EncodeUrl (where can I find it) but I did try HttpUtility.UrlEncode and HttpUtility.UrlPathencode. They both end up routing me to a (non existing) destination file rather then my method :(
borisCallens
HtmlTextWriter.EncodeUrl
Kieveli
HtmlTextWriter.EncodeUrl MethodPerforms minimal URL encoding by converting spaces in the specified URL to the string "%20".spaces are not my problem
borisCallens
http://msdn.microsoft.com/en-us/library/system.web.ui.htmltextwriter.encodeurl(VS.80).aspx
borisCallens
A: 

It's a bit of a hack, but you could replace the ':' with '%3A' (which is the escaped form), and see what the ActionLink does with it. If it's escaped once more, you'd have to replace the twice-escaped version back to ':' at the server, otherwise just replace '%3A' back to ':'

Piskvor