Page 1 of 1

How do you encode a string to use in a URI

Posted: Tue Aug 04, 2015 5:06 pm
by tvu
Hello support and fellow forum users,

I am looking for a way to encode a string into a URI friendly format. I tried to use System.Web.HttpServerUtility.UrlEncode, but that method doesn't exist even though it's been available since .NET 2.0. I vaguely remember reading that we could use any library available in .NET.

I've also tried to use WebUtility.UrlEncode(), but I keep getting the following error message even though Ranorex Studio auto completes the method as I am typing it in:
"The name 'WebUtility' does not exist in the current context"

Here's an example of what I would like to do:
Given string: [email protected]&mvVar=Some Value
Expected string: myemail%40domain.com&mvVar=Some%20Value

Setup Info:
Ranorex Version: 5.4.0.24580
.NET Runtime Version: 4.0.30319.34014

Thanks in advance!

Re: How do you encode a string to use in a URI

Posted: Tue Aug 04, 2015 5:50 pm
by tvu
Nevermind, I figured it out. I didn't have the compiler set to .NET 4.5 in the project settings.

Thanks!