HttpServerUtility.UrlPathEncode vs HttpServerUtility.UrlEncode

前端 未结 3 1007
天涯浪人
天涯浪人 2020-11-30 06:41

What\'s the difference between HttpServerUtility.UrlPathEncode and HttpServerUtility.UrlEncode? And when should I choose one over the other?

3条回答
  •  爱一瞬间的悲伤
    2020-11-30 07:21

    To explain it as simply as possible:

    HttpUtility.UrlPathEncode("http://www.foo.com/a b/?eggs=ham&bacon=1") 
    

    becomes

    http://www.foo.com/a%20b/?eggs=ham&bacon=1
    

    and

    HttpUtility.UrlEncode("http://www.foo.com/a b/?eggs=ham&bacon=1") 
    

    becomes

    http%3a%2f%2fwww.foo.com%2fa+b%2f%3feggs%3dham%26bacon%3d1
    

提交回复
热议问题