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
     
    Goerge Tikakis, Nov 26, 2009
    #1
    1. Advertisements

  2. Goerge Tikakis

    Evertjan. Guest

    Goerge Tikakis wrote on 26 nov 2009 in
    microsoft.public.inetserver.asp.general:
    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., Nov 26, 2009
    #2
    1. Advertisements

  3. So how can i read the whole string?
     
    Goerge Tikakis, Nov 27, 2009
    #3
  4. Goerge Tikakis

    Evertjan. Guest

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

    [please always quote on usenet]
     
    Evertjan., Nov 27, 2009
    #4
  5. Goerge Tikakis

    Dooza Guest

    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:
    Encode what?
     
    Evertjan., Nov 27, 2009
    #6
  7. Goerge Tikakis

    Dooza Guest

    The query string that contains a # symbol.

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

    Dan Guest

    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, Nov 27, 2009
    #8
  9. Goerge Tikakis

    Evertjan. Guest

    Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:
    And you want to do that serverside?

    Impossible.

    And you want to do that clientside?

    Off Topic.
     
    Evertjan., Nov 27, 2009
    #9
  10. Goerge Tikakis

    Dooza Guest

    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
    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, Nov 27, 2009
    #11
  12. Goerge Tikakis

    Evertjan. Guest

    Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:
    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.
     
    Evertjan., Nov 28, 2009
    #12
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
Loading...