Hi Localhost,
Thank you for using Microsoft Newsgroup Service. Based on your description,
you want to get the MAC address info of the client side machine which visit
your ASP.NET web application on the server. Is my understanding correct?
As for this problem, the ASP.NET has provided some buildin classes and
methods for getting client side info. For example,"Request.Browser.***" can
get the client's browser info, "Request.UserHostAddress" can get the client
ip address. However, the MAC address isn't support by the buildin methods
or properties. If we do want to get the remote client's MAC address, we
need to use some scripts, the following code is as a reference:
<%@ LANGUAGE="VBSCRIPT"%>
<%
strIP = Request.ServerVariables("REMOTE_ADDR")
strMac = GetMACAddress(strIP)
strHost = Request.ServerVariables("REMOTE_HOST")
function GetMACAddress(strIP)
Set net = Server.CreateObject("wscript.network")
Set sh = Server.CreateObject("wscript.shell")
sh.run "%comspec% /c nbtstat -A " & strIP & " > d:\inetpub\wwwroot\" &
strIP & ".txt",0,true
Set sh = nothing
Set fso = createobject("scripting.filesystemobject")
Set ts = fso.opentextfile("d:\inetpub\wwwroot\" & strIP & ".txt")
macaddress = null
Do While Not ts.AtEndOfStream
data = ucase(trim(ts.readline))
if instr(data,"MAC ADDRESS") Then
macaddress = trim(split(data,"=")(1))
Exit Do
End if
loop
ts.close
Set ts = nothing
'fso.deletefile "d:\inetpub\wwwroot\" & strIP & ".txt"
Set fso = nothing
GetMACAddress = macaddress
End function
%>
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<%Response.Write("Your IP is : " & strIP & "<BR>" & vbcrlf)%>
<%Response.Write("Your MAC is : " & strMac & vbcrlf)%>
</BODY>
</HTML>
Hope this helps.
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)