Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. problem with HttpRequest.QueryString

problem with HttpRequest.QueryString

Scheduled Pinned Locked Moved C#
helpcsharpxml
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dfn
    wrote on last edited by
    #1

    I have a problem with HttpRequest.QueryString. There is an XML string that contains something like the following: 8+ 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: NameValueCollection coll = Request.QueryString; XMLstring = coll.Get("XMLstr"); // result: XMLstring = "8 " XMLstring = Request.QueryString["XMLstr"]; // result: XMLstring = "8 " XMLstring = Request.QueryString.Get("XMLstr"); // result: XMLstring = "8 " XMLstring = HttpUtility.HtmlDecode(Request.QueryString["XMLstr"]); // result: XMLstring = "8 " XMLstring = HttpUtility.HtmlDecode(Request.QueryString.Get("XMLstr")); // result: XMLstring = "8 " In all of the above cases, XMLstring is a string (string XMLstring = ""; ). I realise I can just search XMLstring and replace the space with the plus sign. I don't want to do that though. Also, this isn't my code, and I have no idea why XML is in QueryString nor if it should be there, never worked with asp or done web stuff in C#, but it has to stay like this for the moment, and I have to somehow extract that + sign. Any help or advice is appreciated. Thanks.

    C G 2 Replies Last reply
    0
    • D dfn

      I have a problem with HttpRequest.QueryString. There is an XML string that contains something like the following: 8+ 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: NameValueCollection coll = Request.QueryString; XMLstring = coll.Get("XMLstr"); // result: XMLstring = "8 " XMLstring = Request.QueryString["XMLstr"]; // result: XMLstring = "8 " XMLstring = Request.QueryString.Get("XMLstr"); // result: XMLstring = "8 " XMLstring = HttpUtility.HtmlDecode(Request.QueryString["XMLstr"]); // result: XMLstring = "8 " XMLstring = HttpUtility.HtmlDecode(Request.QueryString.Get("XMLstr")); // result: XMLstring = "8 " In all of the above cases, XMLstring is a string (string XMLstring = ""; ). I realise I can just search XMLstring and replace the space with the plus sign. I don't want to do that though. Also, this isn't my code, and I have no idea why XML is in QueryString nor if it should be there, never worked with asp or done web stuff in C#, but it has to stay like this for the moment, and I have to somehow extract that + sign. Any help or advice is appreciated. Thanks.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      dfn wrote:

      never worked with asp or done web stuff in C#,

      If this is C#, this is ASP.NET, not asp. And, we have a forum for ASP.NET questions.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • D dfn

        I have a problem with HttpRequest.QueryString. There is an XML string that contains something like the following: 8+ 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: NameValueCollection coll = Request.QueryString; XMLstring = coll.Get("XMLstr"); // result: XMLstring = "8 " XMLstring = Request.QueryString["XMLstr"]; // result: XMLstring = "8 " XMLstring = Request.QueryString.Get("XMLstr"); // result: XMLstring = "8 " XMLstring = HttpUtility.HtmlDecode(Request.QueryString["XMLstr"]); // result: XMLstring = "8 " XMLstring = HttpUtility.HtmlDecode(Request.QueryString.Get("XMLstr")); // result: XMLstring = "8 " In all of the above cases, XMLstring is a string (string XMLstring = ""; ). I realise I can just search XMLstring and replace the space with the plus sign. I don't want to do that though. Also, this isn't my code, and I have no idea why XML is in QueryString nor if it should be there, never worked with asp or done web stuff in C#, but it has to stay like this for the moment, and I have to somehow extract that + sign. Any help or advice is appreciated. Thanks.

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        You can't get the correct value if it's not encoded properly when put in the querystring. This is how the querystring should look like to be correct: ?XMLstr=8%2b

        Despite everything, the person most likely to be fooling you next is yourself.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups