Normally I would just use:
HttpContext.Current.Server.UrlEncode(\"url\");
But since this is a console application, HttpContext.Curren
Best thing is to Add Reference to System.web..dll
and use var EncodedUrl=System.Web.HttpUtility.UrlEncode("URL_TEXT");
You can find the File at System.web.dll
Kibbee offers the real answer. Yes, HttpUtility.UrlEncode is the right method to use, but it will not be available by default for a console application. You must add a reference to System.Web. To do that,
NOW you can use the UrlEncode method. You'll still want to add,
using System.Web
at the top of your console app or use the full namespace when calling the method,
System.Web.HttpUtility.UrlEncode(someString)
Try this!
Uri.EscapeUriString(url);
Or
Uri.EscapeDataString(data)
No need to reference System.Web.
Edit: Please see another SO answer for more...
use the static HttpUtility.UrlEncode method.
I'm not a .NET guy, but, can't you use:
HttpUtility.UrlEncode Method (String)
Which is described here:
HttpUtility.UrlEncode Method (String) on MSDN
HttpUtility.UrlEncode("url") in System.Web.