UrlEncode through a console application?

后端 未结 12 1249
我寻月下人不归
我寻月下人不归 2020-12-15 02:16

Normally I would just use:

HttpContext.Current.Server.UrlEncode(\"url\");

But since this is a console application, HttpContext.Curren

12条回答
  •  爱一瞬间的悲伤
    2020-12-15 03:11

    Try this!

    Uri.EscapeUriString(url);
    

    Or

    Uri.EscapeDataString(data)
    

    No need to reference System.Web.

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

提交回复
热议问题