suvmitra
asked on
Return IPv4 address in VB.NET 2008
The below code snippet is working perfectly ASP.net pages.
I need to return IPv4 address of the client in a vb.net windows application form and need to change this code to work.
HttpContext.Current.Reques t.UserHost Address is not working in windows forms ..pls help.
I need to return IPv4 address of the client in a vb.net windows application form and need to change this code to work.
HttpContext.Current.Reques
Imports System
Imports System.Net
Public Class IPNetworking
Public Shared Function GetIP4Address() As String
Dim IP4Address As String = String.Empty
For Each IPA As IPAddress In Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress)
If IPA.AddressFamily.ToString() = "InterNetwork" Then
IP4Address = IPA.ToString()
Exit For
End If
Next
If IP4Address <> String.Empty Then
Return IP4Address
End If
For Each IPA As IPAddress In Dns.GetHostAddresses(Dns.GetHostName())
If IPA.AddressFamily.ToString() = "InterNetwork" Then
IP4Address = IPA.ToString()
Exit For
End If
Next
Return IP4Address
End Function
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.