.net core ile kullanıcıların mac adresini okuma

 .NET Core ile kullanıcıların MAC adreslerini okumak için aşağıdaki gibi bir kod bloğu kullanabilirsiniz:


using System.Net;

using System.Net.NetworkInformation;


public string GetUserMacAddress()

{

// Kullanıcının IP adresini alıyoruz

string userIP = HttpContext.Connection.RemoteIpAddress.ToString();


// Kullanıcının IP adresine ait MAC adresini alıyoruz

string userMacAddress = string.Empty;

foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())

{

    if (nic.OperationalStatus == OperationalStatus.Up)

    {

        foreach (UnicastIPAddressInformation ip in nic.GetIPProperties().UnicastAddresses)

        {

            if (ip.Address.ToString() == userIP)

            {

                userMacAddress = nic.GetPhysicalAddress().ToString();

                break;

            }

        }

    }

}


// Kullanıcının MAC adresini döndürüyoruz

return userMacAddress;


Bu kod bloğu sayesinde, bir kullanıcının IP adresine ait MAC adresini alabilir ve kullanabilirsiniz. Ayrıca, bu adresi bir veritabanına kaydederek veya diğer işlemlerde kullanabilirsiniz.

Yorumlar

Bu blogdaki popüler yayınlar

Windows’ta Uzantısı Değiştirilmiş Dosyaları Tespit Etme: Powershell ile Pratik Yöntem

.net Core 5.0 ile Mernis (Merkezi Nüfus İdaresi Sistemi) Sistemi Üzerinden T.C. Kimlik No Sorgulama

Google Maps Api Kullanım Örneği ve Json Data Okuma