Home All Groups Group Topic Archive Search About

Get the server name from ASP when accessed by IP address



Author
3 May 2006 9:49 PM
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.

Author
3 May 2006 10:07 PM
Aaron Bertrand [SQL Server MVP]
Not all valid in this case, but you can see:
http://www.aspfaq.com/2263




Show quote
"Steve Lynch" <user@spam.com> wrote in message
news:uRf05tvbGHA.1264@TK2MSFTNGP05.phx.gbl...
>
> 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.
>
>
Author
3 May 2006 10:31 PM
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?


Show quote
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
news:uqTZK1vbGHA.1960@TK2MSFTNGP05.phx.gbl...
> Not all valid in this case, but you can see:
> http://www.aspfaq.com/2263
>
>
>
>
> "Steve Lynch" <user@spam.com> wrote in message
> news:uRf05tvbGHA.1264@TK2MSFTNGP05.phx.gbl...
>>
>> 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.
>>
>>
>
>
Author
4 May 2006 8:04 AM
Patrice
Have you tried also the other solutions mentioned in this article (using
WScript.Network should work ?). This is what we are using...

--
Patrice

"Steve Lynch" <user@spam.com> a écrit dans le message de news:
e6$PYFwbGHA.3***@TK2MSFTNGP04.phx.gbl...
Show quote
>
> 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?
>
>
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in
> message news:uqTZK1vbGHA.1960@TK2MSFTNGP05.phx.gbl...
>> Not all valid in this case, but you can see:
>> http://www.aspfaq.com/2263
>>
>>
>>
>>
>> "Steve Lynch" <user@spam.com> wrote in message
>> news:uRf05tvbGHA.1264@TK2MSFTNGP05.phx.gbl...
>>>
>>> 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.
>>>
>>>
>>
>>
>
>
Author
4 May 2006 3:20 PM
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!


Show quote
"Patrice" <scr***@chez.com> wrote in message
news:e739xF1bGHA.1276@TK2MSFTNGP03.phx.gbl...
> Have you tried also the other solutions mentioned in this article (using
> WScript.Network should work ?). This is what we are using...
>
> --
> Patrice
>
> "Steve Lynch" <user@spam.com> a écrit dans le message de news:
> e6$PYFwbGHA.3***@TK2MSFTNGP04.phx.gbl...
>>
>> 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?
>>
>>
>> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
>> news:uqTZK1vbGHA.1960@TK2MSFTNGP05.phx.gbl...
>>> Not all valid in this case, but you can see:
>>> http://www.aspfaq.com/2263
>>>
>>>
>>>
>>>
>>> "Steve Lynch" <user@spam.com> wrote in message
>>> news:uRf05tvbGHA.1264@TK2MSFTNGP05.phx.gbl...
>>>>
>>>> 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.
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
4 May 2006 9:09 AM
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!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

AddThis Social Bookmark Button