Finding out your local IP in VB .net under IIS 7
If you’re looking for your IP address of your website chances are you know if, but in case you don’t, there are 2 ways to find it. There are also 2 different IP addresses you might be looking for. There’s a local IP address, then the IP address that the outside world sees and can access your web server on.
Here’s a VB .net code section to find your internal IP address, IE, your local IP address of the website on the network.
If ip.Count > 0 Then
For Each ipadd As Net.IPAddress In ip
Me.testdiv.InnerHtml = ipadd.ToString
Here’s a code section to see your outward facing IP address. Notice that you need to import the few things at the top of the code. This simply hits IPchicken.com and displays the results.
Dim reader As StreamReader
Dim request As WebRequest
Dim response As WebResponse
Dim data As String = “”
request = WebRequest.Create(“http://www.ipchicken.com”)
request.Timeout = 30000
response = request.GetResponse()
reader = New StreamReader(response.GetResponseStream())
data = reader.ReadToEnd()
Catch ex As Exception
Me.testdiv.InnerHtml = data