admin管理员组

文章数量:1415491

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

本文标签: cencodeURIComponent in c sharpStack Overflow