asp.net读客户端mac信息(其实就是ActiveX加Javascript)
其中就是通过客户端ActiveX与Javascript读取。
设置浏览器启用ActiveX
工具->Internet选项->安全->自定义级别->
对没有标记为安全的ActiveX控件进行初始化和脚本运行,勾上启用。
把ActiveX控件和插件,全部启用算了。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Javascript读客户端mac信息,IP,计算机名。</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language="JScript" event="OnCompleted(hResult,pErrorObject, pAsyncContext)" for="foo">
document.forms[0].txtMACAddr.value=unescape(MACAddr);
document.forms[0].txtIPAddr.value=unescape(IPAddr);
document.forms[0].txtDNSName.value=unescape(sDNSName);
//document.formbar.submit();
</script>
<script language="JScript" event="OnObjectReady(objObject,objAsyncContext)" for="foo">
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
{
if(objObject.MACAddress != null && objObject.MACAddress != "undefined")
MACAddr = objObject.MACAddress;
if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined")
IPAddr = objObject.IPAddress(0);
if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined")
sDNSName = objObject.DNSHostName;
}
</script>
<meta content="MSHTML 6.00.2800.1106" name="GENERATOR">
</head>
<body>
<object id="locator" classid="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6" viewastext>
</object>
<object id="foo" classid="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223">
</object>
<script language="JScript">
var service = locator.ConnectServer();
var MACAddr ;
var IPAddr ;
var DomainAddr;
var sDNSName;
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
</script>
<form id="formfoo" name="formbar" action="" method="post">
mac信息:<input id="txtMac" value="00-11-11-B4-52-EF" name="txtMACAddr" /><br />
客户端IP:<input value="210.42.38.50" name="txtIPAddr" /><br />
客户端计算机名:<input value="greatverve" name="txtDNSName" />
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Javascript读客户端mac信息,IP,计算机名。</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language="JScript" event="OnCompleted(hResult,pErrorObject, pAsyncContext)" for="foo">
document.forms[0].txtMACAddr.value=unescape(MACAddr);
document.forms[0].txtIPAddr.value=unescape(IPAddr);
document.forms[0].txtDNSName.value=unescape(sDNSName);
//document.formbar.submit();
</script>
<script language="JScript" event="OnObjectReady(objObject,objAsyncContext)" for="foo">
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
{
if(objObject.MACAddress != null && objObject.MACAddress != "undefined")
MACAddr = objObject.MACAddress;
if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined")
IPAddr = objObject.IPAddress(0);
if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined")
sDNSName = objObject.DNSHostName;
}
</script>
<meta content="MSHTML 6.00.2800.1106" name="GENERATOR">
</head>
<body>
<object id="locator" classid="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6" viewastext>
</object>
<object id="foo" classid="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223">
</object>
<script language="JScript">
var service = locator.ConnectServer();
var MACAddr ;
var IPAddr ;
var DomainAddr;
var sDNSName;
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
</script>
<form id="formfoo" name="formbar" action="" method="post">
mac信息:<input id="txtMac" value="00-11-11-B4-52-EF" name="txtMACAddr" /><br />
客户端IP:<input value="210.42.38.50" name="txtIPAddr" /><br />
客户端计算机名:<input value="greatverve" name="txtDNSName" />
</form>
</body>
</html>
asp.net页面只是读一下iframe中的信息。
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GetMac.aspx.cs" Inherits="GetMac" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>asp.net读客户端mac信息</title>
<script type="text/javascript">
function getMac(){
alert(document.getElementById("iframeMac").contentWindow.document.getElementById("txtMac").value);
}
window.onload=function(){
var s=document.getElementById("iframeMac").contentWindow.document.getElementById("txtMac").value;
document.getElementById("txtMac").value=s;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
其中就是通过客户端ActiveX与Javascript读取。<br />
设置浏览器启用ActiveX<br />
工具->Internet选项->安全->自定义级别-><br />
对没有标记为安全的ActiveX控件进行初始化和脚本运行,勾上启用。<br />
把ActiveX控件和插件,全部启用算了。
</div>
<div>
<iframe src="getMac.htm" id="iframeMac" style="display:none;"></iframe>
客户端mac:<asp:TextBox ID="txtMac" runat="server"></asp:TextBox>
<input type="button" onclick="getMac();" value="ok" />
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>asp.net读客户端mac信息</title>
<script type="text/javascript">
function getMac(){
alert(document.getElementById("iframeMac").contentWindow.document.getElementById("txtMac").value);
}
window.onload=function(){
var s=document.getElementById("iframeMac").contentWindow.document.getElementById("txtMac").value;
document.getElementById("txtMac").value=s;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
其中就是通过客户端ActiveX与Javascript读取。<br />
设置浏览器启用ActiveX<br />
工具->Internet选项->安全->自定义级别-><br />
对没有标记为安全的ActiveX控件进行初始化和脚本运行,勾上启用。<br />
把ActiveX控件和插件,全部启用算了。
</div>
<div>
<iframe src="getMac.htm" id="iframeMac" style="display:none;"></iframe>
客户端mac:<asp:TextBox ID="txtMac" runat="server"></asp:TextBox>
<input type="button" onclick="getMac();" value="ok" />
</div>
</form>
</body>
</html>
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。