How to get Mac from Linux win general

Source: Internet
Author: User

Tested the following method to get Mac cross-platform

        protected Override voidOnLoad (EventArgs e) {Response.Write (string. Join ("<br/>", Getmacstring ())); Response.Write ("<br/>");Base.        OnLoad (e); } PublicNetworkinterface[] Netcardinfo () {returnNetworkinterface.getallnetworkinterfaces (); } Public string[] getmacstring () {stringStrmac = ""; Networkinterface[] interfaces = Networkinterface.getallnetworkinterfaces ();foreach(NetworkInterface niinchInterfaces) {if(NI. Operationalstatus = = operationalstatus.up) {Strmac + = ni. Getphysicaladdress (). ToString () + "|"; }            }returnStrmac.split (' | '); }

Related articles:

C #/S program get MAC address three ways http://www.cnblogs.com/yzb305070/archive/2011/04/03/2004364.html

Report:

// <summary>/// Get the server IP for the current request, and the corresponding MAC address// </summary>// <returns>[the server Ip,mac address currently requested]</returns> Public string[] Getrequestipmac () {string[] result =New string[2];stringServerName = page.request.servervariables["server_name"];stringRequestserverip = page.request.servervariables["local_addr"];if(ServerName = = "localhost") {result[0] ="localhost"; }Else{Result[0] = Requestserverip.tolower (); ManagementClass MC =NewManagementClass ("Win32_NetworkAdapterConfiguration"); Managementobjectcollection MOC = MC. GetInstances ();foreach(ManagementObject moinchMOC) {Try{if((BOOL) mo["ipenabled"] ==true)                                {string[] ipaddresses = (string[]) mo["IPAddress"];if(Ipaddresses.length > 0) { for(inti = 0; i < ipaddresses.length; i++) {if(Ipaddresses[i] = = Requestserverip) {Result[1] = mo["MacAddress"]. ToString (). ToLower (); Break; }                                                }                                        }if(! String.IsNullOrEmpty (Result[1])) { Break; }                                }                        }finally{mo.                        Dispose (); }                }        }returnResult;}

How to get Mac from Linux win general

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.