我想:如何解码使用encodeURIComponent()在JS中编码的HTML?
string decodedHtml = HttpUtility.HtmlDecode(html);
如果HTML是编码的HTML。看来这并不会改变字符串。 html仍然是编码的。
我想:如何解码使用encodeURIComponent()在JS中编码的HTML?
string decodedHtml = HttpUtility.HtmlDecode(html);
如果HTML是编码的HTML。看来这并不会改变字符串。 html仍然是编码的。
认为你可以使用这段代码。
HttpContext.Current.Server.UrlDecode(html)
请显示字符串示例 – 2011-05-16 20:18:47
HtmlDecode仅解码使用HtmlEncode编码的值。仅供参考:HtmlEncode与UrlEncode与Uri.EscapDataString之间存在差异。一些有用的信息在这里:http://blogs.msdn.com/b/yangxind/archive/2006/11/09/don-t-use-net-system-uri-unescapedatastring-in-url-decoding.aspx – 2014-05-14 07:19:08
请注意,Asp.Net/Mvc操作通常会将以这种方式编码的url查询参数(encodeURIComponent)自动转换为纯字符串:如果您的操作方法需要“paramName”,它会尝试查找该值作为查询参数(它还会检查表单发布参数)。这被称为“参数绑定”。它还转换更复杂的类型,例如bool,int,float。 – 2014-10-24 21:27:54