Special Characters in Query String

Discussion in 'ASP .Net' started by SMG - Idealake, May 20, 2005.

  1. Hi All,
    I have created an application which is working fine and is in about to
    launch, now suddenly my mgmt says there are chances that Scrip ID( a
    particular id and not prim key) may have special characters like '&,*,) or
    /'

    This data(field/key) I am passing this value as a querystring. e.g.

    value to be passed : ABC
    http://localhost/myProj/abc.aspx?ScripID=ABC
    this works fine,

    But when I have special characters like [ABC&D] then the value retrieved is
    wrong it just retrieves ABC and not complete ID [ABC&D]
    value to be passed : ABC&D
    http://localhost/myProj/abc.aspx?ScripID=ABC&D

    how do I overcome this, I know I can do it like we have %20 for space and
    like wise for & there will be something, but this will be a major change to
    my application, can I do this at one end some where in web.config or in aspx
    page?

    P.S. Hi Juan T. Llibre,
    if you have cracked that things, can you mail me to
    id please.

    Thanks and best regards,
    Shailesh Gajare
     
    SMG - Idealake, May 20, 2005
    #1
    1. Advertising

  2. Use Server.UrlEncode(string)

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Sometimes you eat the elephant.
    Sometimes the elephant eats you.

    "SMG - Idealake" <> wrote in message
    news:...
    > Hi All,
    > I have created an application which is working fine and is in about to
    > launch, now suddenly my mgmt says there are chances that Scrip ID( a
    > particular id and not prim key) may have special characters like '&,*,) or
    > /'
    >
    > This data(field/key) I am passing this value as a querystring. e.g.
    >
    > value to be passed : ABC
    > http://localhost/myProj/abc.aspx?ScripID=ABC
    > this works fine,
    >
    > But when I have special characters like [ABC&D] then the value retrieved
    > is
    > wrong it just retrieves ABC and not complete ID [ABC&D]
    > value to be passed : ABC&D
    > http://localhost/myProj/abc.aspx?ScripID=ABC&D
    >
    > how do I overcome this, I know I can do it like we have %20 for space and
    > like wise for & there will be something, but this will be a major change
    > to
    > my application, can I do this at one end some where in web.config or in
    > aspx
    > page?
    >
    > P.S. Hi Juan T. Llibre,
    > if you have cracked that things, can you mail me to
    >
    > id please.
    >
    > Thanks and best regards,
    > Shailesh Gajare
    >
    >
     
    Kevin Spencer, May 20, 2005
    #2
    1. Advertising

  3. SMG - Idealake

    Patrice Guest

    Give this a try. It shouldn't be a big change as QueryString decodes this
    automatically for you. You'll have just to encode the values using
    Server.URLEncode.

    I don't think you can do better as the system has no way to know
    automatically that the & you have is part of the value instead of being
    taken as a separator (you have to tell this by encoding the value)...

    You could try a test such as :
    Response.Write (Request.QueryString("MyVar"))
    Response.Write("<a href="""?MyVar=" &
    Server.URLEncode("MyValue&/*WithSomeCharacters") & """>Test</a>")

    Patrice

    --

    "SMG - Idealake" <> a écrit dans le message de
    news:...
    > Hi All,
    > I have created an application which is working fine and is in about

    to
    > launch, now suddenly my mgmt says there are chances that Scrip ID( a
    > particular id and not prim key) may have special characters like '&,*,) or
    > /'
    >
    > This data(field/key) I am passing this value as a querystring. e.g.
    >
    > value to be passed : ABC
    > http://localhost/myProj/abc.aspx?ScripID=ABC
    > this works fine,
    >
    > But when I have special characters like [ABC&D] then the value retrieved

    is
    > wrong it just retrieves ABC and not complete ID [ABC&D]
    > value to be passed : ABC&D
    > http://localhost/myProj/abc.aspx?ScripID=ABC&D
    >
    > how do I overcome this, I know I can do it like we have %20 for space and
    > like wise for & there will be something, but this will be a major change

    to
    > my application, can I do this at one end some where in web.config or in

    aspx
    > page?
    >
    > P.S. Hi Juan T. Llibre,
    > if you have cracked that things, can you mail me to


    > id please.
    >
    > Thanks and best regards,
    > Shailesh Gajare
    >
    >
     
    Patrice, May 20, 2005
    #3
  4. re:
    > P.S. Hi Juan T. Llibre,
    > if you have cracked that things, can you mail me to id please.


    SMG,

    What Jorg and I are working on regards file encoding.
    Your problem relates to query string encoding.

    The answer to the problem Jorg and I are working on will not
    help you solve the problem you're having with query string encoding.

    In any case, there will be at least a 2 week delay, since I'm going on an
    11 day trip starting today and won't be able to work on this in the meantime.

    Jorg and I will post the resolution to the file encoding problem
    as soon as we finish the analysis ( which is fairly complex... ).




    Juan T. Llibre
    ASP.NET MVP
    http://asp.net.do/foros/
    Foros de ASP.NET en Español
    Ven, y hablemos de ASP.NET...
    ======================

    "SMG - Idealake" <> wrote in message
    news:...
    > Hi All,
    > I have created an application which is working fine and is in about to
    > launch, now suddenly my mgmt says there are chances that Scrip ID( a
    > particular id and not prim key) may have special characters like '&,*,) or
    > /'
    >
    > This data(field/key) I am passing this value as a querystring. e.g.
    >
    > value to be passed : ABC
    > http://localhost/myProj/abc.aspx?ScripID=ABC
    > this works fine,
    >
    > But when I have special characters like [ABC&D] then the value retrieved is
    > wrong it just retrieves ABC and not complete ID [ABC&D]
    > value to be passed : ABC&D
    > http://localhost/myProj/abc.aspx?ScripID=ABC&D
    >
    > how do I overcome this, I know I can do it like we have %20 for space and
    > like wise for & there will be something, but this will be a major change to
    > my application, can I do this at one end some where in web.config or in aspx
    > page?
    >
    > P.S. Hi Juan T. Llibre,
    > if you have cracked that things, can you mail me to
    > id please.
    >
    > Thanks and best regards,
    > Shailesh Gajare
    >
    >
     
    Juan T. Llibre, May 20, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SMG
    Replies:
    20
    Views:
    16,062
    =?Utf-8?B?TWF2ZXJpY2s=?=
    May 25, 2005
  2. Stefan Mueller
    Replies:
    3
    Views:
    33,048
    Stefan Mueller
    Jul 23, 2006
  3. Replies:
    2
    Views:
    1,096
    Ingo Menger
    May 31, 2007
  4. Sunshine Valdes

    Special Characters in passed Query String

    Sunshine Valdes, Sep 8, 2003, in forum: ASP General
    Replies:
    2
    Views:
    319
    Adrienne
    Sep 11, 2003
  5. Sobin Thomas
    Replies:
    5
    Views:
    829
    Mike Brind [MVP]
    May 21, 2008
Loading...

Share This Page