Strange problem with Request

G

Goerge Tikakis

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
 
E

Evertjan.

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,
 
E

Evertjan.

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]
 
D

Dan

Goerge Tikakis said:
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.
 
E

Evertjan.

Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:
The query string that contains a # symbol.

And you want to do that serverside?

Impossible.

And you want to do that clientside?

Off Topic.
 
D

Dooza

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.

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
 
A

Adrienne Boswell

Gazing into my crystal ball I observed Goerge Tikakis
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 %>
 
E

Evertjan.

Dooza wrote on 27 nov 2009 in microsoft.public.inetserver.asp.general:
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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top