Strange problem with Request

Discussion in 'ASP General' started by Goerge Tikakis, Nov 26, 2009.

  1. Hello
    Today suddenly i realize that when a querystring has the # sign then the
    request stops at that sign.

    I mean if you have www.domain.com/test.asp?test=12#12

    then

    when you write

    response.write request("test") you only have the 12 because it stops at
    the #

    Is this a bug? how can i prevent this?
    I've also checked with dot.net same thing

    Thank you

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Goerge Tikakis, Nov 26, 2009
    #1
    1. Advertising

  2. Goerge Tikakis

    Evertjan. Guest

    Goerge Tikakis wrote on 26 nov 2009 in
    microsoft.public.inetserver.asp.general:

    > Today suddenly i realize that when a querystring has the # sign then the
    > request stops at that sign.
    >
    > I mean if you have www.domain.com/test.asp?test=12#12
    >
    > then
    >
    > when you write
    >
    > response.write request("test") you only have the 12 because it stops at
    > the #
    >
    > Is this a bug? how can i prevent this?
    > I've also checked with dot.net same thing


    This is a clientside defined behavour,
    as the part behind the # is the anchor.

    Nothing to do with serverside behavour.

    However it is easily circumvented clientside,
    but that is OT here,

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Nov 26, 2009
    #2
    1. Advertising

  3. Goerge Tikakis, Nov 27, 2009
    #3
  4. Goerge Tikakis

    Evertjan. Guest

    Goerge Tikakis wrote on 27 nov 2009 in
    microsoft.public.inetserver.asp.general:

    > So how can i read the whole string?
    >


    What string?

    [please always quote on usenet]

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Nov 27, 2009
    #4
  5. Goerge Tikakis

    Dooza Guest

    Goerge Tikakis wrote:
    >
    > So how can i read the whole string?


    Maybe encode it?

    Dooza
     
    Dooza, Nov 27, 2009
    #5
  6. Goerge Tikakis

    Evertjan. Guest

    Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:

    > Goerge Tikakis wrote:
    >>
    >> So how can i read the whole string?

    >
    > Maybe encode it?


    Encode what?

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Nov 27, 2009
    #6
  7. Goerge Tikakis

    Dooza Guest

    Evertjan. wrote:
    > Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:
    >
    >> Goerge Tikakis wrote:
    >>> So how can i read the whole string?

    >> Maybe encode it?

    >
    > Encode what?


    The query string that contains a # symbol.

    Dooza
     
    Dooza, Nov 27, 2009
    #7
  8. Goerge Tikakis

    Dan Guest

    "Goerge Tikakis" <> wrote in message
    news:...
    >
    >
    > Hello
    > Today suddenly i realize that when a querystring has the # sign then the
    > request stops at that sign.
    >
    > I mean if you have www.domain.com/test.asp?test=12#12
    >
    > then
    >
    > when you write
    >
    > response.write request("test") you only have the 12 because it stops at
    > the #
    >
    > Is this a bug? how can i prevent this?
    > I've also checked with dot.net same thing
    >


    As Evertjan has already pointed out, it's expected behaviour. Is it your own
    page generating the querystring? If so, you need to change it so it doesn't
    use #, but instead uses the encoded version (you simply need to use
    Server.URLEncode to do this).

    eg.

    strValue = "12#12"
    Response.Write "test.asp?test=" & strValue

    could be replaced with

    strValue = "12#12"
    Response.Write "test.asp?" & Server.URLEncode(strValue)

    the Server.URLEncode method will handle encoding the # so it no longer acts
    as an anchor in the URL, but instead is part of the value for test in the
    Request collection.

    But as you have provided no example code for how you are generating the
    URLs, this is about the best I can offer.

    --
    Dan
     
    Dan, Nov 27, 2009
    #8
  9. Goerge Tikakis

    Evertjan. Guest

    Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:

    > Evertjan. wrote:
    >> Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:
    >>
    >>> Goerge Tikakis wrote:
    >>>> So how can i read the whole string?
    >>> Maybe encode it?

    >>
    >> Encode what?

    >
    > The query string that contains a # symbol.


    And you want to do that serverside?

    Impossible.

    And you want to do that clientside?

    Off Topic.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Nov 27, 2009
    #9
  10. Goerge Tikakis

    Dooza Guest

    On 27/11/2009 14:52, Evertjan. wrote:
    > Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:
    >
    >> Evertjan. wrote:
    >>> Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:
    >>>
    >>>> Goerge Tikakis wrote:
    >>>>> So how can i read the whole string?
    >>>> Maybe encode it?
    >>>
    >>> Encode what?

    >>
    >> The query string that contains a # symbol.

    >
    > And you want to do that serverside?
    >
    > Impossible.
    >
    > And you want to do that clientside?
    >
    > Off Topic.


    As Dan said, without seeing the source code you can't tell what he is doing.

    Dan's example shows a serverside way of doing it before its received by
    the Request object, which is the only way.

    If the user is entering # in a form, then it needs some clientside
    validation to either prevent it or encode it, which is certainly off topic.

    Dooza
     
    Dooza, Nov 27, 2009
    #10
  11. Gazing into my crystal ball I observed Goerge Tikakis
    <> writing in news:OGgjcisbKHA.1596
    @TK2MSFTNGP06.phx.gbl:

    >
    >
    > Hello
    > Today suddenly i realize that when a querystring has the # sign then

    the
    > request stops at that sign.
    >
    > I mean if you have www.domain.com/test.asp?test=12#12
    >
    > then
    >
    > when you write
    >
    > response.write request("test") you only have the 12 because it stops

    at
    > the #
    >
    > Is this a bug? how can i prevent this?
    > I've also checked with dot.net same thing
    >
    > Thank you
    >


    What you are talking about is a URL fragment. It is used to get the
    browser (client side) to go to a particular id or anchor.

    Since it is client side, you cannot read its value server side because
    you never get it. You can, however, add it to a url to redirect or
    construct a nice anchor, eg:

    <ul>
    <% for i = 0 to 50%>
    <li><a href="<%=request.servervariables("Script_name")%>#<%i%>>Go to
    Paragraph <%i%></a><li>
    <% next %>
    </ul>
    <% for i = 0 to 50 %>
    <p id="<%=i%>">Paragraph <%=i%></p>
    <%next %>

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Nov 27, 2009
    #11
  12. Goerge Tikakis

    Evertjan. Guest

    Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:

    > On 27/11/2009 14:52, Evertjan. wrote:
    >> Dooza wrote on 27 nov 2009 in
    >> microsoft.public.inetserver.asp.general:
    >>
    >>> Evertjan. wrote:
    >>>> Dooza wrote on 27 nov 2009 in
    >>>> microsoft.public.inetserver.asp.general:
    >>>>
    >>>>> Goerge Tikakis wrote:
    >>>>>> So how can i read the whole string?
    >>>>> Maybe encode it?
    >>>>
    >>>> Encode what?
    >>>
    >>> The query string that contains a # symbol.

    >>
    >> And you want to do that serverside?
    >>
    >> Impossible.
    >>
    >> And you want to do that clientside?
    >>
    >> Off Topic.

    >
    > As Dan said, without seeing the source code you can't tell what he is
    > doing.
    >
    > Dan's example shows a serverside way of doing it before its received
    > by the Request object, which is the only way.


    Which is not very usefull more often than not, as the querystring usually
    is formed from data that depends on clientside user influence.

    If not, these data can better be kept serverside in a session variable.

    [Unless we are talking cross-domain.]

    Using post in stead of querystring is also a good habit.


    > If the user is entering # in a form, then it needs some clientside
    > validation to either prevent it or encode it, which is certainly off
    > topic.
    >
    > Dooza




    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Nov 28, 2009
    #12
    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. Marina

    Strange Request Size problem

    Marina, Jun 30, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    366
    Marina
    Jun 30, 2003
  2. Brian Birtle
    Replies:
    2
    Views:
    2,052
    John Saunders
    Oct 16, 2003
  3. Chris
    Replies:
    0
    Views:
    591
    Chris
    May 20, 2004
  4. Paul
    Replies:
    1
    Views:
    430
  5. Aaron Prohaska

    Very strange page request problem

    Aaron Prohaska, Jan 21, 2004, in forum: ASP General
    Replies:
    7
    Views:
    146
    Paul Baker
    Jan 22, 2004
Loading...

Share This Page