Marco
Marco

Reputation: 65

How to pass special characters in a parameter for URL

Here is an example parameter value I' m trying to pass:

ABC_DE:1-5KSP7TRP:New year, SEO, ++ Solids

I've tried to encode the special values with this code:

REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(Fields!ID.Value.ToString(),"&","%2526"),"+","%2B"),"-","%2D"),",","%2C"),":","%3A")

I've tried removing the ToString(), but that didn't seem to help. Do I also have to encode the spaces as well? The symbols I've replaced so far are &, +,-, ,, and :. Any help would be appreciated, thanks!

Upvotes: 0

Views: 711

Answers (1)

Chris Latta
Chris Latta

Reputation: 20560

Don't worry about all the special characters - System.Web already does the heavy lifting for you. Add System.Web to your project references and then use

System.Web.HttpUtility.UrlEncode(URLStringToEncode)

Upvotes: 1

Related Questions