Frontpage 2003 - Global.asa question

K

Kevin Spencer

You can use JavaScript to parse the document.location property, which is the
URL, and use string manipulation to get the domain name, by parsing out the
string between the 2 dots.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
C

clintonG

This person is obviously using ASP as noted by the mention of
the global.asa file. It is much easier to use ASP than JavaScript
for this task.

It must also be noted that quite frequently it is not possible to
determine how or from where somebody attempted to request a
page on a website. I'm not going to write a whole tutorial on this
but it is an indisputable fact.

Put this ASP into any page that uses an .asp file extension...

<% Dim sReferredFrom
sReferredFrom = Request.ServerVariables("HTTP_REFERER")
Response.Write(sReferredFrom)
%>

Note: when used as a variable in code the word 'referer' is and
must be spelled incorrectly.

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
 
F

Fred

Thanks for your help on my question.

Yes. I'm trying to write a dynamic ASP website based on the URL/Domain name
the user used to get to the site.

What I had hoped to do is create a session variable "session('sitename')"
when the session is created based on the domain name and refer to
session('sitename') to vary the content on ASP pages.

Here's my thoughts in an example:

1) Register three domain names - www.joes-bookstore.com,
www.mikes-bookstore.com, www.sams-bookstore.com and have them all point to
the same website.

2) Build a dynamic bookstore website that uses ASP code to vary the page
content based on what domain name is being used.


Is this possible?

Thanks

Fred
 
K

Kevin Spencer

Sure it's possible. Use Request.ServerVariables("SERVER_NAME") to get the
domain name that they requested from the HTTP headers sent by the browser.
You can then set your Session value and continue with whatever.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
C

clintonG

Except I've already noted that there are several reasons why
this tactic is not reliable. Briefly, there are about 3-5 reasons
why the request object will never contain any data regardless
of what server variable is used.

Don't forget to include such shortcoming in your design strategy.
Maybe Kevin can take his time to confirm this as he seems to
have conveniently forgotten. :)

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
 
K

Kevin Spencer

I haven't forgotten anything. I used this very technique in a similar
situation several years ago, with a client who just sold his web site for
600K.

If the user enters an IP address instead of a domain name (unlikely, but
possible), it will be necessary to have a default web site from one of the
domain names available. Other than that, it's no problemo.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
C

clintonG

I wish I could meet a client that would pay me to spread the manure.

I am pointing out -- as I did in my first reply -- that this technique we
are discussing -- using the Request object to capture data in the server
variables collection -- is not reliable -- and if it is to be used, the design
of the code should include some form of responding to the several
instances why the server variables may never be populated with data
and in fact the business strategy itself must be considered to even
use this methodology as there may be other ways to skin the cat.

I'm not going to repeat myself again.

What you had to say about the IP address is incorrect. Requesting a
page by using an IP address is easy enough to capture in code when
using the Request object unless of course one of the several points
of failure are involved.

Manually typing the URL into the address bar is in fact one of several
instances why the Request object will not be populated with data and it
would not matter if what was manually entered was an IP address or
a well formed URL. Loading a page from Favorites is another. There
are others.

Assuming you are technically competent, you would have learned this by
trial and error or by study -- eventually -- but why you choose to spread
the manure and care not enough to even make a simple comment warning
about this fact while trying to 'help' a neophyte remains between you and
your maker and anybody foolish enough to trust that kind of 'advice.'

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
 
K

Kevin Spencer

I speak not only from experience, but from knowledge. I have used ASP since
it first appeared, and have authored books and articles on the subject of
ASP. While criticising my advice, you bring up no actual facts or data, only
innuendo. You obviously are not here to help, but with your own agenda, one
that doesn't serve anyone but yourself.

However, for the benefit of others, I will answer your innuendo: The Request
object is simply an object made up of the various text elements of an HTTP
Request. The ASP Request.ServerVariables Collection is derived by parsing
the Request and the headers in it. In the case of
Request.ServerVariables("SERVER_NAME"), the value in the Collection is the
domain name of the path requested by the browser. For example, if you
request http://www.microsoft.com/default.asp, "microsoft.com" is the domain
name portion of the Requested URL. EVERY REQUEST includes either a domain
name, machine name, or an IP address. This variable will NEVER be empty.

What you are ignorantly proclaiming is in relation to
Request.ServerVariables("HTTP_REFERER"), which will indeed be empty if the
browser was just opened, and the URL was either typed in, or a favorite was
used, as the HTTP_REFERER is the URL of the page that linked to the current
one to bring the browser there.

The blanket statement "several instances why the server variables may never
be populated with data" indicates that there are instances where NO Server
Variables will be populated with data. If you knew what they were, you would
know how ridiculous that assertion is.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

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

Top