i am using Dim IPAddress IPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR") If IPAddress = "" Then IPAddress = Request.ServerVariables("REMOTE_ADDR") End If but i am getting 127.0.0.1 i suppose i am getting it due to my local host
based on this ip i need to find the country of that IP using vb.net or javascript. how ca i achieve it
>based on this ip i need to find the country of that IP using vb.net or javascript. how ca i achieve it
Getting Country from IP address is somewhat problematical. For example whist I have been in the United Kingdom, I have been told that I am in Germany one and in America at another time.
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
var useraddress = Request.UserHostAddress;
var test = IPAddress.Parse(useraddress);
var result = CommonData.IPAddressToBytes(test);
lblOutput.Text = result[0] + "." + result[1] + "." + result[2] + "." + result[3];
This displays (not surpringly) 127.0.0.1
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
svibuk
Member
717 Points
1733 Posts
Re: Get users IP address
Jan 20, 2009 08:53 AM|LINK
i am using Dim IPAddress IPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR") If IPAddress = "" Then IPAddress = Request.ServerVariables("REMOTE_ADDR") End If but i am getting 127.0.0.1 i suppose i am getting it due to my local host
based on this ip i need to find the country of that IP using vb.net or javascript. how ca i achieve it
hope to get help
country ip address
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Get users IP address
Jan 20, 2009 01:56 PM|LINK
>based on this ip i need to find the country of that IP using vb.net or javascript. how ca i achieve it
Getting Country from IP address is somewhat problematical. For example whist I have been in the United Kingdom, I have been told that I am in Germany one and in America at another time.
Code for Address look up
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
villandro
Member
2 Points
3 Posts
Re: Get users IP address
Jan 22, 2009 02:04 PM|LINK
Dim clientIP as String = Request.UserHostAddress.ToString
lblShowIp.Text = clientIP
yrb.yogi
Star
14460 Points
2402 Posts
Get users IP address
Jan 28, 2009 09:14 AM|LINK
Get Users IP address...???
but How???
can u expalin me????
.Net All About
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Get users IP address
Jan 28, 2009 09:32 AM|LINK
http://forums.asp.net/p/1360555/2807643.aspx#2807643
Contact me
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Get users IP address
Jan 28, 2009 09:40 AM|LINK
You can get the user's IP Address by:
var useraddress = Request.UserHostAddress;
For details, see:
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Get users IP address
Jan 28, 2009 09:45 AM|LINK
Or more fully using the function I gave earlier.
var useraddress = Request.UserHostAddress;
var test = IPAddress.Parse(useraddress);
var result = CommonData.IPAddressToBytes(test);
lblOutput.Text = result[0] + "." + result[1] + "." + result[2] + "." + result[3];
This displays (not surpringly) 127.0.0.1
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
sunnyhasan
Member
2 Points
3 Posts
Re: Get users IP address
May 02, 2009 06:58 AM|LINK
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
Is the uppoer statement returning the client ip address? That is a hexcode. But IP address should not be in that format right?
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(1).ToString(); I have used this GetValue(1) instead GetValue(0).
Is that ok? Can you please explain that? I need to log all the ip address of the users when they visit a specific website...please help me.
Thanks.
-http://sunnyhasan.blogspot.com
ip ip address
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Get users IP address
May 02, 2009 09:39 AM|LINK
Try
var ipAddress = Request.UserHostAddress.ToString();
or if using an earlier version of the framework
string ipAddress = Request.UserHostAddress.ToString();
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
Promas
Member
2 Points
1 Post
Re: Get users IP address
May 24, 2009 04:58 AM|LINK
Please try with this
<%
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(1).ToString();
Response.Write(clientIPAddress);
%>
Thanks