HttpContext.Current.Server.UrlEncode
This does only work in .NET Framework. How can I encode or decode URI arguments in ASP.NET Core?
For ASP.NET Core 2.0+ just add System.Net namespace - WebUtility class is shipped as part of System.Runtime.Extensions nuget package, that is referenced by default in ASP.NET Core project.
System.Net
WebUtility
System.Runtime.Extensions
For the previous version add Microsoft.AspNetCore.WebUtilities nuget package.
Microsoft.AspNetCore.WebUtilities
Then the WebUtility class will be available for you:
public static class WebUtility { public static string UrlDecode(string encodedValue); public static string UrlEncode(string value); }
1.4m articles
1.4m replys
5 comments
57.0k users