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 ***
> 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)
So how can i read the whole string?
> So how can i read the whole string?
>
What string?
[please always quote on usenet]
Maybe encode it?
Dooza
Encode what?
The query string that contains a # symbol.
Dooza
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
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
>
>
> 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
> 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
--