- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
HttpServerUtility.UrlPathEncode
有什么区别和 HttpServerUtility.UrlEncode
?我什么时候应该选择一个?
最佳答案
更新:从 4.5 开始,根据 MSDN 引用,Microsoft 建议仅使用 UrlEncode。此外,先前在 MSDN 中列出的信息并未完全描述这两种方法的行为 - 请参阅注释。
区别在于空间转义 - UrlEncode 将它们转义为 + 符号,UrlPathEncode 将它们转义为 %20。 + 和 %20 仅当它们是 QueryString 部分的一部分时才等效 per W3C .所以你不能使用 + 号转义整个 URL,只有查询字符串部分。底线是 UrlPathEncode 总是更好 imho
You can encode a URL using with the UrlEncode() method or the UrlPathEncode() method. However, the methods return different results. The UrlEncode() method converts each space character to a plus character (+). The UrlPathEncode() method converts each space character into the string "%20", which represents a space in hexadecimal notation. Use the UrlPathEncode() method when you encode the path portion of a URL in order to guarantee a consistent decoded URL, regardless of which platform or browser performs the decoding.
关于asp.net - HttpServerUtility.UrlPathEncode 与 HttpServerUtility.UrlEncode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4145823/
我有这个: file://localhost/Volumes/Untitled%20RAID%20Set%201/Callum/iTunes/Music/Steppenwolf/Steppenwolf
MSDN page for UrlPathEncode指出不应使用 UrlPathEncode,我应该改用 UrlEncode。 Do not use; intended only for brows
我有带空格的 Url,想用 %20 替换空格(转义)。 UrlPathEncode 应该这样做,但它不适用于下面有空格的 url。有人可以解释为什么它不起作用吗? System.Web.HttpUti
有什么区别 HttpUtility.UrlPathEncode(params); 和 HttpUtility.UrlEncode(params); 我查看了 MSDN 页面 https://msdn.
我正在尝试对我的 Silverlight 项目中的 URL 中的 Unicode 字符进行编码。我想使用 HttpUtility.UrlPathEncode (Source) 但是,这个 版本的 Ht
HttpServerUtility.UrlPathEncode有什么区别和 HttpServerUtility.UrlEncode ?我什么时候应该选择一个? 最佳答案 更新:从 4.5 开始,根据
为什么 .NET 的文档为 HttpUtility.UrlPathEncode对于 .NET 4.5 状态 Do not use; intended only for browser compatib
我找到了 a brilliant example使用 HTMLAgilityPack 的 HTML sanitizer 。在代码中,使用了 Microsoft.Security.Application
在最近的一个项目中,我有幸解决了一个错误,该错误涉及文件名中有空格时无法加载图像。我想“多么简单的问题,我会UrlEncode()它!”但是,不!只需使用 UrlEncode()没有解决问题。 新问题
我是一名优秀的程序员,十分优秀!