[.NET/.NET Core]ASP.NET Core应用程序中如何对URL地址进行编码(Encode)或者解码(Decode)呢?
3.46K 次浏览
1 个回答
-
在ASP.NET Core 2.0及以上版本中,安装
System.Runtime.Extension程序包,位于System.Net命名空间下的WebUtility类中提供了URL编码和解码的方法,内置的方法如下:public static class WebUtility { public static string UrlDecode(string encodedValue); public static string UrlEncode(string value); }使用示例如下:
var encodeUrl = System.Net.WebUtility.UrlEncode(url);