0

I have a webmethod and get my queryString with this code:

string name = "";
        int pos7 = context.Request.UrlReferrer.PathAndQuery.IndexOf("name");
        if (pos7 >= 0)
            name = context.Request.UrlReferrer.PathAndQuery.Substring(pos7 + 5);

The problem is the adresse "www.test.com?name=tiki song" will be end up in "tiki%20song" on my string.

How to avoid that?

(Yes I could replace the %20 to " " but there are a lot of more of that kind, right?"

PassionateDeveloper
  • 14,558
  • 34
  • 107
  • 176

2 Answers2

1

Consider using Uri.UnescapeDataString

http://msdn.microsoft.com/en-us/library/system.uri.unescapedatastring.aspx

LuFaMa
  • 346
  • 1
  • 6
  • 15
0

As per this previous you could create a URI and extract it using "UnescapeDataString" (post). Referencing this MSDN page.

Or alternatively, you can use some of the HtmlDecode methods as MikeBarkemeyer had mentioned in the comments.

Community
  • 1
  • 1
ImGreg
  • 2,946
  • 16
  • 43
  • 65