bez*_*eny 68 c# asp.net asp.net-mvc asp.net-core-mvc asp.net-core
我想知道是否有替换System.Web.HttpUtility.UrlEncode和UrlDecode.
正如我发现Encode它应该是: Microsoft.Framework.WebEncoders.UrlEncoder.Default.UrlEncode.
但我没有找到UrlDecode.有吗?
Mih*_*scu 119
System.Runtime.Extensions定义了UrlDecode和HtmlDecode.
namespace System.Net
{
public static partial class WebUtility
{
public static string HtmlDecode(string value) { return default(string); }
public static string HtmlEncode(string value) { return default(string); }
public static string UrlDecode(string encodedValue) { return default(string); }
public static byte[] UrlDecodeToBytes(byte[] encodedValue, int offset, int count) { return default(byte[]); }
public static string UrlEncode(string value) { return default(string); }
public static byte[] UrlEncodeToBytes(byte[] value, int offset, int count) { return default(byte[]); }
}
}
Run Code Online (Sandbox Code Playgroud)
在System.Runtime.Extensions定义扩展时,您可以从它的代码中注意到您需要调用的实际类System.Net.WebUtility
选项1:System.Net.WebUtility
目前,还没有公开作出的计划,包括Decode在Microsoft.Framework.WebEncoders.
用法
System.Net.WebUtility.UrlEncode(myString)
System.Net.WebUtility.UrlDecode(myString)
Run Code Online (Sandbox Code Playgroud)
选项2:System.Text.Encodings.Web.UrlEncoder
这是在asp.net核心服务容器中注册的,可以注入您的控制器等.