what c# class method can I use to URL encode a URL string?
In my use case I want to pass a URL string as a URL parameter itself. So like burying a URL within a URL. Without some encoding the "&" and "?" characters in the inner URL can get picked up when the parameters for the outer Url parameters are processed
thanks
System.Net.WebUtility.UrlEncode(str)
HttpServerUtility.UrlEncode
might be exactly what you are looking for.
Use Server.UrlEncode
You need an instance of the HttpServerUtility class, because the UrlEncode method is not static.
See http://msdn.microsoft.com/en-us/library/system.web.httpserverutility(v=VS.90).aspx
I am operating with .net framework 2.0. But it never shows me "UrlEncode" intelisense when I place dot after httpserverutility. Here are the options I see:
HttpServerUtility.Equals
HttpServerUtility.ReferenceEquals
HttpServerUtility.UrlTokenDecode
HttpServerUtility.UrlTokenEncode
That's it, these are the only options I see. Could I possibly ask for small piece of code as an example to use url encode function?
Thanks,
Linda