UrlEncode through a console application?

.net, c#, console

Solution

Try this!

Uri.EscapeUriString(url);

Or

Uri.EscapeDataString(data)

No need to reference System.Web.

Edit: Please see another SO answer for more...

Problem

Normally I would just use: ``` HttpContext.Current.Server.UrlEncode("url"); ``` But since this is a console application, `HttpContext.Current` is always going to be `null`. Is there another method that does the same thing that I could use?

Original source

Related problems