Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the real IP
Message
De
17/09/2013 10:55:48
 
 
À
17/09/2013 01:57:24
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01583370
Message ID:
01583399
Vues:
45
This resolves the issue:
    ' Return the IP address
    Public Function GetIP() As String
        Dim lcIP As String = ""
        Dim loNetworkInterface As System.Net.NetworkInformation.NetworkInterface = Nothing
        Dim loNetworkInterfaces As System.Net.NetworkInformation.NetworkInterface() = Nothing
        Dim loUnicastIPAddressInformation As System.Net.NetworkInformation.UnicastIPAddressInformation = Nothing

        ' Initialization
        loNetworkInterfaces = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()

        ' For each network interface
        For Each loNetworkInterface In loNetworkInterfaces

            ' If this is our primary adapter
            If loNetworkInterface.NetworkInterfaceType = System.Net.NetworkInformation.NetworkInterfaceType.Wireless80211 OrElse _
             loNetworkInterface.NetworkInterfaceType = System.Net.NetworkInformation.NetworkInterfaceType.Ethernet Then

                ' For each IP address
                For Each loUnicastIPAddressInformation In loNetworkInterface.GetIPProperties().UnicastAddresses

                    ' If this the primary IP address
                    If loUnicastIPAddressInformation.Address.AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork Then
                        lcIP = loUnicastIPAddressInformation.Address.ToString()
                    End If

                Next

            End If

        Next

        Return lcIP
    End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform