function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

urlEncode replace underscores

Hi all,


urlEncode dosn't appear to be replacing underscores with the correct url safe representation, any ideas why this might be? Also is there a way to use post instead of get with a PageReference?




Message Edited by Scott.M on 03-23-2009 12:26 PM

I am not sure that is a bug.  It looks like the underscore is a valid character for an encoded URL.

If you needed it encoded specifically, you could manually substitute the hex value yourself, the trick is, would your tarket system be able to decode it correctly.

As for the Post question, instead of using a pagereference, you could always create a custom HTTP Request method to do your post action.  Look in the documentation for HTTPRequest.


Thanks Jim,


You're right underscores are a valid character for URL's just not for salesforce. If there are underscores in a query parameter in a visualforce page salesforce says the page doesn't exist. For now I'm base64 encoding and decoding the parameters that have underscores which seems to be working.   




Now THAT might be the bug.  I haven't tested to see if that worked or not.

Was you issue with the underscore in the parameter name, or the value?


The underscores were in the parameter value. I was trying to pass a custom object type and field name. Here's an example of what the url looks lik:





e r i c.ax249e r i c.ax249

I've run into this same issue and came up on this thread while searching.  It seems that when you have "Development Mode" enabled for a user and there are two underscores in a row in the querystring, VF pages will display the error message that the VF page does not exist.  It must be a bug.