Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a method called using restExtension. I want to pass URL as a parameter. As URL has "/" it is giving me an error because it treats as separate parameters. Ex : Base/GetJSONPage/About-Us/What-We-Do. I want About-Us/What-We-Do as one parameters where as umbraco treat is as two parameters.
I tried using overload methods but restExtension does not recognize them and giving me Ambiguous methods error. Can't use any characters instead of "/" as user gets confused.
Thinking about creating a handler but if anybody has solution for this it would be appriciated.
Have you tried to use HttpUtility.UrlEncode()? Encode the url, pass it to the restExtension and then encode it back using HttpUtility.UrlDecode().
Thank you for your reply. I don't think it is possible to encode URL without changing the /Base. I rather go with generic handler though the URL is not pretty.
I bumped into this same problem recently, where I needed to pass a URL as a parameter to base, and oddly I wasn't able to find a solution to this anywhere.
longUrl = encodeURIComponent(longUrl);
However, the per cent and dot characters remain after this, and will still cause a problem. This is where the "hacking" comes in. I replace these characters with other characters which (hopefully) won't appear in most URLs:
longUrl = longUrl.replace(/\%/g, "€"); longUrl = longUrl.replace(/\./g, "£");
This seems to be sufficient for the rest extension method to receive the parameter, but it's a mess at this time, of course, so I have to process the string to restore it to the original. Or in my case, to a URIComponent-encoded string:
longUrl = longUrl.Replace("€", "%"); longUrl = longUrl.Replace("£", ".");
You may, of course, decode this to end up with the original url.
I see that you mention that you can't ask the user to replace the characters themselves, but would it be possible to use an event handler to do the replacing and pass the request on to base?
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted