Option Explicit On
Option Strict On
Imports System.Net
Public Class GetMAC
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim macAddress As String = ""
For Each nic As System.Net.NetworkInformation.NetworkInterface In System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
If nic.OperationalStatus = Net.NetworkInformation.OperationalStatus.Up And nic.GetPhysicalAddress.ToString.Length = 12 Then
macAddress = nic.GetPhysicalAddress.ToString
End If
Next
Dim ip As String = ""
Dim strHostName As String = System.Net.Dns.GetHostName()
Dim iphe As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(strHostName)
For Each ipheal As System.Net.IPAddress In iphe.AddressList
If ipheal.AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork Then
ip = ipheal.ToString()
End If
Next
Response.Write(ip)
Response.Write(macAddress)
End Sub
End Class