0

I have the following string LIVEWIRE TS+

When I do the following code:

  <a href="/support/knowledge-base?category=@Server.UrlEncode("LIVEWIRE TS+")" class="topic-knowledge-base button">KNOWLEDGE BASE</a>

It produces the following query string:

LIVEWIRE+TS%2b

I thought a space was %20 when encoded.

Ok, after decoding it, I got back LIVEWIRE TS, but not LIVEWIRE TS+. How can I retain the + sign?

xaisoft
  • 3,343
  • 8
  • 44
  • 72
  • 2
    See http://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20 – xanatos Mar 04 '16 at 14:55
  • 1
    + is spacebar and %20 is plus sign. – Sousuke Mar 04 '16 at 14:55
  • 1
    no space is '+' when encoded if you want you can check it here http://www.url-encode-decode.com/ – Tushar Gupta Mar 04 '16 at 14:56
  • @Sousuke - When i decode the value, I lost the + sign, I need to keep that. – xaisoft Mar 04 '16 at 15:26
  • The fact that `+` is used to encode a space is unrelated to your problem and your result shows that that part got decoded correctly. The complete string `LIVEWIRE+TS%2b` is supposed to decode to `LIVEWIRE TS+` though, as one answer already shows. Can you show your code that's doing the decoding? –  Mar 07 '16 at 09:12
  • @Sousuke `+` can sometimes be space. `%20` is space as well, but always. Only `%2b` is a URL encoding of a plus sign. –  Mar 07 '16 at 09:13
  • My bad, sure %20 is space and %2b is plus. – Sousuke Mar 07 '16 at 09:24

1 Answers1

0

To decode it to get the same string you have to use this code:

System.Net.WebUtility.UrlDecode("LIVEWIRE+TS%2b");

And it will return LIVEWIRE TS+.

Sousuke
  • 1,203
  • 1
  • 15
  • 25