|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Get the server name from ASP when accessed by IP address
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. 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. > > 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. >> >> > > 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. >>> >>> >> >> > > 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. >>>> >>>> >>> >>> >> >> > > 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 "Display" in the sense of "display in the address bar"?> 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. <% 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) |
|||||||||||||||||||||||