如何获得客户端的域名、机器名

Ryan73 2003-06-09 07:36:25
在ASP中如何获得客户端的机器名、域名,以及如何获得和显示在线人员的IP或机器名,当然他退出网页时也在网页自动动掉该人员。谢谢!
...全文
231 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
fhbkyo 2003-06-10
  • 打赏
  • 举报
回复
不会吧,还没解决吗?楼主怎么不说话
lyj0243122 2003-06-09
  • 打赏
  • 举报
回复
up
qdkcy 2003-06-09
  • 打赏
  • 举报
回复
如果有的计算机用了代理服务器,取得的IP就是代理服务器的IP
arbeng2002 2003-06-09
  • 打赏
  • 举报
回复
获得一些如客户端,服务端信息的一般都是用ServerVariables
上面各位的代码都很详细了,你可以好好看看的啊
qiao198 2003-06-09
  • 打赏
  • 举报
回复
这样什么都得到了。
<%
dim objbc
Set objBC=Server.CreateObject("MSWC.BrowserType")
%>
用户浏览器的版本:<% = objBC.Version %>

现给你一个较全的:

<%
Set objBC=Server.CreateObject("MSWC.BrowserType")
%>
<html><head><style>
td {font-size: 12px}
.red {color: #D00000}
.blue {color: #0000D0}
</style><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>提取与 ASP 相关的服务器或客户端的一些信息</title></head>

<body bgcolor=#85a3ff>
<center><span style="width: 760;font-size:28px;color:#f0f000;font-family:隶书;
position:relative;filter:glow(color=#0060b0, strength=5)">
<b>提取与</b> ASP <b>相关的服务器或客户端的一些信息</b></span></center>
<table border=1 cellSpacing=1 cellPadding=2 align=center width=710
bordercolorlight="#ACDFCC" bordercolordark="#600000" bgcolor=#ffffff height="283">
<tr><td colspan=5 class=12 align=right bgcolor=#85a3ff height="12">
898</td></tr>
<tr><td class=blue height="12">浏览器端相关信息:</td>
<td class=red colspan=4 height="12">  <%= Request.ServerVariables("http_user_agent") %></td></tr>
<tr><td class=blue width=140 height="10">目前网页虚拟路径:</td>
<td class=red width=177 height="10">  <%= Request.ServerVariables("path_info") %></td>
<td width=10 rowspan=13 bgcolor=#85a3ff height="238"></td>
<td class=blue width=130 height="10">本网页的实际路径:</td>
<td class=red width=243 height="10">  <%= Request.ServerVariables("path_Translated") %></td></tr>
<tr><td class=blue height="12">服务器端的IP地址:</td>
<td class=red height="12">  <%= Request.ServerVariables("local_addr") %></td>
<td class=blue height="12">服务器软件的版本:</td>
<td class=red height="12">  <%= Request.ServerVariables("server_software") %></td>
<tr><td class=blue height="12">服务器连接口编号:</td>
<td class=red height="12">  <%= Request.ServerVariables("server_port") %></td>
<td class=blue height="12">服务器的HTTP版本:</td>
<td class=red height="12">  <%= Request.ServerVariables("server_Protocol") %></td></tr>
<tr><td class=blue height="12">远程主机的名称:</td>
<td class=red height="12">  <%= Request.ServerVariables("remote_host") %></td>
<td class=blue height="12">远程主机的IP地址:</td>
<td class=red height="12">  <%= Request.ServerVariables("remote_addr") %></td></tr>
<tr><td class=blue height="12">服务器的名称或IP:</td>
<td class=red height="12">  <%= Request.ServerVariables("server_name") %></td>
<td class=blue height="12">描述内容的语系:</td>
<td class=red height="12">  <%= Request.ServerVariables("http_accept_language") %></td></tr>
<tr><td class=blue height="12">站点主目录的位置:</td>
<td class=red height="12">  <%= Server.MapPath("/") %></td>
<td class=blue height="12">本网页所在位置:</td>
<td class=red height="12">  <%= Server.MapPath("./") %></td></tr>
<tr><td class=blue height="12">本网页上一级目录:</td>
<td class=red height="12">  <%= Server.MapPath("../") %></td>
<td class=blue height="12">服务器端CGI版本:</td>
<td class=red height="12">  <%= Request.ServerVariables("gateway_interface") %></td></tr>
<tr><td class=blue height="12">子与母端联机类型:</td>
<td class=red height="12">  <%= Request.ServerVariables("http_connection") %></td>
<td class=blue height="12">浏览器端主机名:</td>
<td class=red height="12">  <%= Request.ServerVariables("http_host") %></td></tr>
<tr><td class=blue height="12">用户浏览器的名称:</td>
<td class=red height="12">  <% = objBC.Browser %></td>
<td class=blue height="12">用户浏览器的版本:</td>
<td class=red height="12">  <% = objBC.Version %></td></tr>
<tr><td class=blue height="12">是否BETA测试软件:</td>
<td class=red height="12">  <% = objBC.Beta %></td>
<td class=blue height="12">ActiveXControls:</td>
<td class=red height="12">  <% = objBC.ActiveXControls %></td></tr>
<tr><td class=blue height="12">是否支持背景声音:</td>
<td class=red height="12">  <% = objBC.BackgroundSounds %></td>
<td class=blue height="12">是否支持 Cookies:</td>
<td class=red height="12">  <% = objBC.Cookies %></td></tr>
<tr><td class=blue height="12">是否支持框架网页:</td>
<td class=red height="12">  <% = objBC.Frames %></td>
<td class=blue height="12">是否支持表格网页:</td>
<td class=red height="12">  <% = objBC.Tables %></td></tr>
<tr><td class=blue height="12">支持 JavaScript:</td>
<td class=red height="12">  <% = objBC.JavaScript %></td>
<td class=blue height="12">是否支持VBScript:</td>
<td class=red height="12">  <% = objBC.VBScript %></td></tr>
</table>
<% Set objBC=Nothing %>
</body>

<%
function browser(info)
if Instr(info,"MSIE 5.5")>0 then
browser="Internet Explorer 5.5"
elseif Instr(info,"MSIE 6.0")>0 then
browser="Internet Explorer 6.0"
elseif Instr(info,"MSIE 5.01")>0 then
browser="Internet Explorer 5.01"
elseif Instr(info,"MSIE 5.0")>0 then
browser="Internet Explorer 5.00"
elseif Instr(info,"MSIE 4.0")>0 then
browser="Internet Explorer 4.01"
else
browser="未知"
end if
end function
function system(info)
if Instr(info,"NT 5.1")>0 then
system=system+"Microsoft Windows XP"
elseif Instr(info,"NT 5")>0 then
system=system+"Microsoft Windows 2000"
elseif Instr(info,"NT 4")>0 then
system=system+"Microsoft Windows NT4"
elseif Instr(info,"98")>0 then
system=system+"Microsoft Windows 98"
elseif Instr(info,"95")>0 then
system=system+"Microsoft Windows 95"
else
system=system+"未知"
end if
end function
Response.write "您的操作系统是:"&system(Request.ServerVariables("HTTP_USER_AGENT"))&"<br/>"
Response.write "您的浏览器版本是:"&browser(Request.ServerVariables("HTTP_USER_AGENT"))
%>
</html>
fhbkyo 2003-06-09
  • 打赏
  • 举报
回复
都说完啊?白来了,提醒一下,获得一些如客户端,服务端信息的一般都是用ServerVariables的,给你个例子,它用来实现服务端的大部分信息:
<html>
<head><title>服务器变量ServerVariables</title></head>
<body>
<h2 align=center>服务器变量ServerVariables</h2>
<ol>
<% For Each Item In Request.ServerVariables %>
 <li> <% =Item %> = <% =Request.ServerVariables(Item) %>
<% Next %>
</ol>
</body>
</html>
coffee_cn 2003-06-09
  • 打赏
  • 举报
回复
<%@language=vbscript%>
<table border="1" cellpadding="0" cellspacing="0" width="100%" bordercolorlight="#FFFFFF">
<tr>
<td width="23%">
<p align="center">ServerVariables</td>
<td width="77%">
<p align="center">Value</td>
</tr>
<%for each name in Request.ServerVariables%>
<tr>
<td width="23%">  <%=name%></td>
<td width="77%">  <%=Request.ServerVariables(name)%></td>
</tr>
<%next%>
</table>


这段代码对你也会有些帮助
Struggling 2003-06-09
  • 打赏
  • 举报
回复
楼上说的真详细。
wanghr100 2003-06-09
  • 打赏
  • 举报
回复
ServerVariables 集合比较常用的一些参数:

ALL_HTTP 客户端发送的所有 HTTP 标题文件。
CONTENT_LENGTH 客户端发出内容的长度。
CONTENT_TYPE 内容的数据类型。如:"text/html"。同附加信息 的查询一起使用,如 HTTP 查询 GET、POST 和 PUT。
LOCAL_ADDR 返回接受请求的服务器地址。如果在绑定多 个 IP 地址的多宿主机器上查找请求所使用的地址 时,这条变量非常重要。
LOGON_USER 用户登录 Windows NT 的帐号
QUERY_STRING 查询 HTTP 请求中问号(?)后的信息。
REMOTE_ADDR 发出请求的远程主机 (client) 的 IP 地址。
REMOTE_HOST 发出请求的主机 (client) 名称。如果服务器无此 信息,它将设置为空的 MOTE_ADDR 变量。
REQUEST_METHOD 该方法用于提出请求。相当于用于 HTTP 的 GET、HEAD、POST等 等。
SERVER_NAME 出现在自引用 URL 中的服务器主机名、DNS 化名 或 IP 地址。
SERVER_PORT 发送请求的端口号。
HTTP_ACCEPT_LANGUAGE 机器使用的语言环境
ServerVariables 集合对象的语法是什么?

例:

<HTML><HEAD><TITLE>取得客户端的环境参数</TITLE></HEAD>
<BODY>
<%Dim Language
'用以储存Client端环境用的语言
Response.Write "本地IP地址:" & Request.ServerVariables ( "LOCAL_ADDR" )Response.Write "<HR>"Response.Write "服务器IP地址:" & Request.ServerVariables ( "REMOTE_ADDR" )Language = Request.ServerVariables ( "HTTP_ACCEPT_LANGUAGE" )
Response.Write "<HR>主机名称:" & Request.ServerVariables ( "REMOTE_HOST" )
Response.Write " <HR> "Select Case Language Case "zh-tw" : Response.Write "您使用的是繁体中文" Case "zh-cn" : Response.Write "您使用的是简体中文"End Select%>
<HR>
</BODY></HTML>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧