This sample code shows how to retrieve the MAC address of your computer using C#.
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) // only return MAC Address from first card
{
if ((bool)mo["IPEnabled"] == true) MACAddress = mo["MacAddress"].ToString();
}
mo.Dispose();
}
MACAddress = MACAddress.Replace(":", "");
return MACAddress;
}
i think u can not get the client mac address untill u r using windows authentication. The code posted here wud work if u run the code on local development server but on IIS, it wont work.
nandu_232231...
Member
95 Points
86 Posts
how to get client MacAddress
Sep 01, 2009 05:59 AM|LINK
Good Morning Friend
how To Get Client MacAddress. this is basically for validate user for login.
Plz Mark AS Answer if Any Help
shabirhakim1
Star
13496 Points
2145 Posts
Re: how to get client MacAddress
Sep 01, 2009 06:14 AM|LINK
hI,
This sample code shows how to retrieve the MAC address of your computer using C#.
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) // only return MAC Address from first card { if ((bool)mo["IPEnabled"] == true) MACAddress = mo["MacAddress"].ToString(); } mo.Dispose(); } MACAddress = MACAddress.Replace(":", ""); return MACAddress; }nandu_232231...
Member
95 Points
86 Posts
Re: how to get client MacAddress
Sep 01, 2009 06:39 AM|LINK
Hello Shabir
Thanks for reply me
Sorry To say, but i think i getting server Mac address
i have checked it offline or online both.
i mean where my site is opening and just checking is my pc mac address or another pc so do
validate.
do u have another
Plz Mark AS Answer if Any Help
Rahul_Kumar
Member
34 Points
12 Posts
Re: how to get client MacAddress
Sep 01, 2009 06:48 AM|LINK
i think u can not get the client mac address untill u r using windows authentication. The code posted here wud work if u run the code on local development server but on IIS, it wont work.
Ram Reddy Me...
Star
9604 Points
1314 Posts
Re: how to get client MacAddress
Sep 01, 2009 05:18 PM|LINK
Hope the discussion on the same at here will help you.
http://forums.asp.net/p/950261/1156717.aspx
Abhiram Reddy Mekha