URLEncode

  • Thread starter Thread starter Stephen Costanzo
  • Start date Start date
S

Stephen Costanzo

I have to translate a URL so that the parameters in the URL include the
'special' characters for the ?, & and other features.

I have looked at the HttpServerUtility.URLEncode function and it seems to be
the correct method to call to conduct this translation. However I cannot
figure out how to get it to work.

I have tried
HttpServerUtility translate;
translate = System.Web.HttpContext.Current.Server;
string htmlUrlEncoded = translate.UrlEncode(htmlCode);
without success. I know I need to somehow create an object to actually do
the translation, but I am not running a webserver on the development machine
(which is why the Current.Server is probably failing).

Does anyone have any ideas?

Thanks in advance.
 
use the HttpUtility class in the System.Web namespace
it has a static method UrlEncode(string) that does the job.

HTH
Cois
 
Back
Top