In a B/S system, we often need to obtain some information about the client, such as IP and MAC, for identity authentication. In ASP. NET, it is easy to get the MAC address of the server, but it is really easy to get the MAC address of the client. The common practice is to call Win32API or directly call the nbtstat command, there are a lot of problems with this, and the other method is to directly use the client script. Here we use Javascript. The advantage of this is that it does not need to be processed by the server, but can be obtained by the client itself, it is passed to the server, and the speed and reliability are better than those obtained on the server.
The specific implementation of html and javascript is as follows:
<HTML> <HEAD> <TITLE> WMI Scripting HTML </TITLE> <META http-equiv = Content-Type content = "text/html; charset = gb2312 "> <META content =" MSHTML 6.00.2800.1106 "name = GENERATOR> </HEAD> <BODY> <OBJECT id = locator classid = CLSID: export VIEWASTEXT> </OBJECT> <OBJECT id = foo classid = CLSID: 75718C9A-F029-11d1-A1AC-00C04FB6C223> </OBJECT> </BODY> </HTML>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
The key is to use two ActiveX:
<OBJECT id = locator classid = CLSID: 76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT> </OBJECT>
<OBJECT id = foo classid = CLSID: 75718C9A-F029-11d1-A1AC-00C04FB6C223> </OBJECT>
However, these two ActiveX methods are provided by the system and do not need to be downloaded or registered.
The next job is to use scripts to interact with ActiveX. The script can be js or Vbs. I personally like to use js.