Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with Request.ServerVariables("URL")

0 views
Skip to first unread message

PaulY

unread,
Oct 27, 1999, 3:00:00 AM10/27/99
to
I have written an include file to display a table of links, so that I can
put the same info in each page that I write without having reweated code.
This works fine, expept that I don't want a link appearing that takes the
user back to the same page. Therefore I'm using
Request.ServerVariables("URL") to look at the url of the current page, and
display/not display information accordingly. I have implemented it like
this:

' do not display link to the current page
If InStr(1, Request.ServerVariables("URL"), "menu.asp") = 0 Then
Response.Write "<a href=""menu.asp"">Menu</a>"
End If

And this works!
Sometimes!
Unfortunately it only works second time round, if I follow a the link to
menu.asp from the page menu.asp - then the link isn't displayed like I would
expect. Basically the code above only works when the referring page is the
same as the current page.

Any ideas appreciated,

Paul

Cowboy

unread,
Oct 28, 1999, 3:00:00 AM10/28/99
to
On Wed, 27 Oct 1999 16:04:46 +0100, "PaulY" <ya...@hotmailNOSPAM.com>
wrote:

Try setting a variable with the page name at the top of the page. You
can still leave the script in an include, but the page name is
supplied by the page in a variable.

pagename = "menu.asp"

....
If pagename <> "menu.asp" then
...

Using the URL in this manner is okay, but is not the best use of
objects.

GB

PaulY

unread,
Oct 28, 1999, 3:00:00 AM10/28/99
to
Cowboy <NoSpAmM...@home.comNoSpAmM> wrote in message
news:cbgXOF6CPQcJ6c...@4ax.com...

Yes, this workaround does fix the problem.
Presumably this is a bug in ASP then?

Thanks

Paul


Cowboy

unread,
Oct 29, 1999, 3:00:00 AM10/29/99
to
On Thu, 28 Oct 1999 09:37:16 +0100, "PaulY" <ya...@hotmailNOSPAM.com>
wrote:

>
>Yes, this workaround does fix the problem.
>Presumably this is a bug in ASP then?
>
>Thanks
>
>Paul
>
>
>
>

Paul:

Not sure if it is a bug or not. It is more a performance issue to me.
Since hardcoding the name of the page is not really any worse than
getting URL, why have the expense of calling the object when you can
pull a variable. I will see if I can find any info on the Server
variable URL, however, because I am curious.

GB

PaulY

unread,
Oct 29, 1999, 3:00:00 AM10/29/99
to
Cowboy <NoSpAmM...@home.comNoSpAmM> wrote in message
news:QPUYOEjRKAoNII...@4ax.com...

A friend who uses O'Reilly's Website, not IIS (as I do), could not replicate
the problem.

Paul


PaulY

unread,
Oct 29, 1999, 3:00:00 AM10/29/99
to
PaulY <ya...@hotmailNOSPAM.com> wrote in message
news:7v746h$emk$1...@news1.cableinet.co.uk...

> I have written an include file to display a table of links, so that I can
> put the same info in each page that I write without having reweated code.
> This works fine, expept that I don't want a link appearing that takes the
> user back to the same page. Therefore I'm using
> Request.ServerVariables("URL") to look at the url of the current page, and
> display/not display information accordingly. I have implemented it like
> this:
>
> ' do not display link to the current page
> If InStr(1, Request.ServerVariables("URL"), "menu.asp") = 0 Then
> Response.Write "<a href=""menu.asp"">Menu</a>"
> End If
>
> And this works!
> Sometimes!
> Unfortunately it only works second time round, if I follow a the link to
> menu.asp from the page menu.asp - then the link isn't displayed like I
would
> expect. Basically the code above only works when the referring page is
the
> same as the current page.

Worked it out!!

It works if I use the vbTextCompareOption in InStr (to force case
insensitivity), as Request.ServerVariables("URL") doesn't work properly.

I had tried all combinations of cases but was getting unpredictable results.

The reason is this: Request.ServerVariables("URL") capitalises the filename
part of it's output when the referring page is different to the current
page. Otherwise it makes it all lower case. Quite ridiculous really.

Paul


0 new messages