加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – HttpServerUtility.UrlPathEncode vs HttpServerUtil

发布时间:2020-12-16 00:46:25 所属栏目:asp.Net 来源:网络整理
导读:HttpServerUtility.UrlPathEncode和HttpServerUtility.UrlEncode有什么区别?何时应该选择一个呢? 解决方法 更新:从4.5开始,根据MSDN参考,Microsoft建议仅使用UrlEncode。此外,以前在MSDN中列出的信息并没有完全描述两种方法的行为 – 请参阅注释。 区
HttpServerUtility.UrlPathEncode和HttpServerUtility.UrlEncode有什么区别?何时应该选择一个呢?

解决方法

更新:从4.5开始,根据MSDN参考,Microsoft建议仅使用UrlEncode。此外,以前在MSDN中列出的信息并没有完全描述两种方法的行为 – 请参阅注释。

区别在于所有的空间转义 – UrlEncode将它们转义为符号,UrlPathEncode转义为。并且仅当它们是QueryString部分per W3C的一部分时才是等效的。因此,您不能使用符号,只有querystring部分来转义整个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.

07001

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读