C#, asp website: problem with of HttpRequest.QueryString ("+" char decoded to space)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zman77
    New Member
    • Sep 2007
    • 17

    #1

    C#, asp website: problem with of HttpRequest.QueryString ("+" char decoded to space)

    I have a problem with HttpRequest.Que ryString.

    There is an XML string that contains something like the following: <age>8+</age>
    As you probably guessed, the "+" is the problem :)
    I want to get that XML string from QueryString, however, the "+" appears as a " " (space), not a "+".

    I have tried the following:

    Code:
    NameValueCollection coll = Request.QueryString;
    XMLstring = coll.Get("XMLstr");	// result: XMLstring = "<age>8 </age>"
    Code:
    XMLstring = Request.QueryString["XMLstr"];	// result: XMLstring = "<age>8 </age>"
    Code:
    XMLstring = Request.QueryString.Get("XMLstr");	// result: XMLstring = "<age>8 </age>"
    Code:
    XMLstring = HttpUtility.HtmlDecode(Request.QueryString["XMLstr"]);	// result: XMLstring = "<age>8 </age>"
    Code:
    XMLstring = HttpUtility.HtmlDecode(Request.QueryString.Get("XMLstr"));	// result: XMLstring = "<age>8 </age>"
    ** note: XMLstring is a string (decleration: string XMLstring = "";)


    I realise I can just search XMLstring and replace the space with the plus sign. I don't want to do that :)
    Also, this isn't my code, and I have no idea why XML is in QueryString nor if it should be there, but it
    has to stay like this for the moment, and I have to somehow extract that + sign.

    Any help/advice is appreciated.
    Thank you.
  • kunal pawar
    Contributor
    • Oct 2007
    • 297

    #2
    u can used HTMLEncode or HTMLDecode functions provided in server object

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Yes, you will need to encode your XML string BEFORE it gets to the querystring I believe.

      Comment

      Working...