Get Mac Address in ASP.Net

by kad1r 9. February 2010 10:18
This is really useful snipet for getting Mac address.
But first you need to add reference to System.Management.

public string GetMACAddress()
    {
        ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
        ManagementObjectCollection moc = mc.GetInstances();
        string MACAddress = String.Empty;
        foreach (ManagementObject mo in moc)
        {
            if (MACAddress == String.Empty)
            {
                if ((bool)mo["IPEnabled"] == true) MACAddress = mo["MacAddress"].ToString();
            }
            mo.Dispose();
        }
 
        MACAddress = MACAddress.Replace(":", "");
        return MACAddress;
    } 

Comments

2/24/2010 9:44:11 PM #

PVC Banners

When I originally commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I get four emails with the same comment.
Is there any way you can remove me from that service?
Thanks!

PVC Banners United States | Reply

2/24/2010 9:45:39 PM #

Pop Up Stands

I have recently started using the blogengine.net and I having some problems here? in your blog you stated that we need to enable write permissions on the App_Data folder...unfortunately I don't understand how to enable it.

Pop Up Stands United States | Reply

Add comment




  Country flag


  • Comment
  • Preview
Loading





Powered by BlogEngine.NET 1.5.0.7
Keywords: MVC, ASP.Net, Csharp, visual tutorials, SQL, Ubuntu
VisualStudio.Gen.Tr

Widgets

Follow kad1r on Twitter
ÇözümPark

Wordle

kad1r.com - wordle