Get the server name from ASP when accessed by IP address

S

Steve Lynch

Is there a way to display the server's host name or computer name from ASP when
the page was accessed by IP address? I tried dumping all the variables and
header information, but when the URL is accessed using the IP address, the
variables like SERVER_NAME and HTTP_HOST are sent to the web browser as the IP
address.
 
S

Steve Lynch

Thanks for the reply, but I won't be able to change the permissions to access
WMI on these servers. This needs to run as IUSR_%COMPUTERNAME% with default
IIS6 security.

Any other ideas?
 
P

Patrice

Have you tried also the other solutions mentioned in this article (using
WScript.Network should work ?). This is what we are using...
 
E

Evertjan.

Steve Lynch wrote on 03 mei 2006 in
microsoft.public.inetserver.asp.general:
Is there a way to display the server's host name or computer name from
ASP when the page was accessed by IP address? I tried dumping all the
variables and header information, but when the URL is accessed using
the IP address, the variables like SERVER_NAME and HTTP_HOST are sent
to the web browser as the IP address.

"Display" in the sense of "display in the address bar"?

<%
If Request.ServerVariables("SERVER_NAME") = "123.456.789.123" Then
Response.Redirect "http://www.myDomainByName.xyz" &_
Request.ServerVariables("PATH_INFO")
End If
%>

or perhaps:

<%
If Request.ServerVariables("SERVER_NAME") =_
Request.ServerVariables("LOCAL_ADDR") Then
Response.Redirect "http://www.myDomainByName.xyz" &_
Request.ServerVariables("PATH_INFO")
End If
%>

Not tested!
 
S

Steve Lynch

Thanks Aaron and Patrice, The first time I totally missed the WScript portion of
the first example, and only saw the "SERVER_NAME" & "LOCAL_ADDR" part. This
seems to be working fine, thanks!
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top