Google Answers Logo
View Question
 
Q: Getting the computer's IP address with Visual Basic .Net ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Getting the computer's IP address with Visual Basic .Net
Category: Computers > Programming
Asked by: faith16-ga
List Price: $5.00
Posted: 01 Apr 2003 09:42 PST
Expires: 01 May 2003 10:42 PDT
Question ID: 184323
How do you get the computer's IP address with Visual Basic .Net,
preferably using code?
Answer  
Subject: Re: Getting the computer's IP address with Visual Basic .Net
Answered By: missy-ga on 01 Apr 2003 10:00 PST
Rated:5 out of 5 stars
 
Hi there!

Abstract VB offers code for finding your local IP address:

"To find your IP address we first ask for your machine name, then we
pass that to the GetHostName function that gives us a valid
IPHostEntry object. This object contains your IP address in the
AddressList array, so we just dump the value to the console.

 Dim h As System.Net.IPHostEntry =
System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
 Console.WriteLine(CType(h.AddressList.GetValue(0),
IPAddress).ToString) "


Find your IP Address
http://abstractvb.com/code.asp?A=1038

Instructions for obtaining a visitor's IP address follow:

"There are two server variables of interest; REMOTE_ADDR and
HTTP_X_FORWARDED_FOR. As many visitors access the internet via a third
party (ie their ISP), REMOTE_ADDR does not always contain their IP
address... it contains their ISP's address. If this is the case, most
browsers then store the users IP address in the HTTP_X_FORWARDED_FOR
variable. So, first, we check HTTP_X_FORWARDED_FOR, and then if that
is empty, we try REMOTE_ADDR instead:

Dim sIPAddress

sIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If sIPAddress="" Then sIPAddress =
Request.ServerVariables("REMOTE_ADDR") "

Get the visitor's IP address
http://www.developerfusion.com/show/1626/

Hope that helps!

--Missy

Search terms:  [ "VB.NET" "IP address" ]
faith16-ga rated this answer:5 out of 5 stars
Thank you so much! I've spent hours trying to find the answer to this
and within 10 minutes you've solved it.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy