Finding out the domain name

U

UJ

I have a need to know what the domain name is when I'm running a site.
Essentially the problem I have is that I let the user build a web page and
then I display it using a IFRAME. But the IFRAME wants the entire path, not
just relative. So I need to build entire URL. I can store it in a database
but the problem then becomes people running SSL vs. not SSL so I'll need to
do some manipulation.

Anybody got any suggestions?

TIA - Jeffrey.
 
S

S. Justin Gengo

UJ,

I take care of this type of problem using two components I built for just
this purpose...

One is an "ApplicationObject" in which I just store a few properties like
the website url and file paths if I'm working with a file system. The other
is a pageutilities object which builds out full paths based on a relative
uri passed into it and the path contained in the application object. The
application object has properties for different paths to be placed in it for
each of the places the website could be running. In the environment I work
in that's localhost, development, staging, and finally production. The
application object has an environment property that I set to the environment
I'm about to deploy the site to before I build and then those are the paths
used.

Both objects are available for download and use free of charge on my
website, www.aboutfortunate.com. Just click on the "Code Libray" link at the
top and then both objects are available via that buttons on the left
(Application and Page Utilities).

There is also a help file for download which contains info about all the
components on my site.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
B

Bruce Barker

the client sends it in a header, check Request.ServerVariables["HTTP_HOST"]

-- bruce (sqlwork.com)
 
U

UJ

This is all well and good. But I need something that will figure out the
domain just from the page as it's loaded. So in theory if I'm running off
the localhost, I should be able to figure out it's running http://localhost.
I don't want to have to set it up - I need to have code that figures it out
for me.

Thanks anyway.

J.
 
J

Juan T. Llibre

Request.ServerVariables("http_host")

will give you that info, both for localhost and for DNS domains.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top