c# - encodeURIComponent in c sharp - Stack Overflow

I've tried to use HttpUtility.UrlEncode in order to simulate the javscript's encodeURICompone

I've tried to use HttpUtility.UrlEncode in order to simulate the javscript's encodeURIComponent, but had some issues (instead of getting "%20" i got "+")

then I've replaced the string, but i see that the problem is not only in these two signs, in some places the encoded string (by UrlEncode) is totally different from the encoded string by using encodeURIComponent.

Any ideas how it can be solved ?

thanks.

I've tried to use HttpUtility.UrlEncode in order to simulate the javscript's encodeURIComponent, but had some issues (instead of getting "%20" i got "+")

then I've replaced the string, but i see that the problem is not only in these two signs, in some places the encoded string (by UrlEncode) is totally different from the encoded string by using encodeURIComponent.

Any ideas how it can be solved ?

thanks.

Share Improve this question asked Sep 25, 2011 at 12:57 IgalIgal 4,78314 gold badges45 silver badges70 bronze badges 4
  • 3 Possible duplicate: stackoverflow./questions/86477/… – as-cii Commented Sep 25, 2011 at 13:01
  • it's not a duplicate, as i said, my problem is not in "+" or "%20%" but in wrong encoding... when i use c# encoder, i get different chars than the encodeURIComponent encoding... – Igal Commented Sep 25, 2011 at 13:18
  • 2 What if you try Uri.EscapeUriString("some uri...")? – as-cii Commented Sep 25, 2011 at 20:52
  • 1 Possible duplicate of Does C# have an equivalent to JavaScript's encodeURIComponent()? – Adrian Commented Sep 19, 2018 at 4:04
Add a ment  | 

1 Answer 1

Reset to default 1

You are looking for HttpUtility.UrlPathEncode.

See this SO question: Server.UrlEncode vs. HttpUtility.UrlEncode

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745208633a4616713.html

相关推荐

  • c# - encodeURIComponent in c sharp - Stack Overflow

    I've tried to use HttpUtility.UrlEncode in order to simulate the javscript's encodeURICompone

    6小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信