I happy that such code is well doing but one problem arise when Client(Under Proxy server) who access my application return the Proxy server IP.U have some code to Find the IP Address of client run under Proxy server.
Hi All i have same problem,after read this post i got the IP address, then i want to get the time zone of the Ip Address.how to get the timezone of the particular IP address..
>I want to get the time zone of the Ip Address.how to get the timezone of the particular IP
IP Address is frequently wrong even on country let alone Time Zone within a country. Whilst being in the UK, I have been told that according to my IP address one time I was in Germany and another in the US. Given the way IP address blocks are allocated
to an Internet Service Provider, it is quite lilely that a national ISP in the US willl have users from a different time zone to where that block is registered.
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
#region " Copyleft "
// Copyright (C) 2008 Clive Chinery
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#endregion
namespace Demo
{
using System;
using NUnit.Framework;
/// <summary>
/// IpAddressTest
/// </summary>
[TestFixture]
public class IpAddressTest
{
/// <summary>
/// Test GetBlock1
/// </summary>
[Test]
public void GetBlock1Test1()
{
Assert.AreEqual("123", GetBlock1("123.111.222.103"));
}
/// <summary>
/// Test GetBlock1
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentException))]
public void GetBlock1Test2()
{
Assert.AreEqual("123", GetBlock1("123.111.222"));
}
/// <summary>
/// Get Block 1
/// </summary>
/// <param name="input">IP Address</param>
/// <returns>Block 1</returns>
public string GetBlock1(string input)
{
var work = (string.Empty + input).Split('.');
if (work.Length != 4)
{
throw new ArgumentException("input is not in form xxx.xxx.xxx.xxx");
}
return work[0];
}
}
}
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
dr_maq
Member
8 Points
5 Posts
Re: Get users IP address
Jun 26, 2008 05:53 AM|LINK
It worked for me
Great
kfrivera
Member
2 Points
9 Posts
Re: Get users IP address
Oct 20, 2008 05:58 AM|LINK
Hi! Thanks for the post.. It works! [Yes]
But how about getting the default gateway?
Thanks in advance!
Rajeev673
Member
2 Points
1 Post
Re: Get users IP address
Oct 23, 2008 06:15 AM|LINK
I happy that such code is well doing but one problem arise when Client(Under Proxy server) who access my application return the Proxy server IP.U have some code to Find the IP Address of client run under Proxy server.
Thanks
Desigank
Member
4 Points
5 Posts
Re: Get users IP address
Nov 07, 2008 06:07 AM|LINK
Hi All i have same problem,after read this post i got the IP address, then i want to get the time zone of the Ip Address.how to get the timezone of the particular IP address..
Thanks in Advance,
Desigan.k
TATWORTH
All-Star
72405 Points
14018 Posts
MVP
Re: Get users IP address
Nov 10, 2008 06:41 AM|LINK
>I want to get the time zone of the Ip Address.how to get the timezone of the particular IP
IP Address is frequently wrong even on country let alone Time Zone within a country. Whilst being in the UK, I have been told that according to my IP address one time I was in Germany and another in the US. Given the way IP address blocks are allocated to an Internet Service Provider, it is quite lilely that a national ISP in the US willl have users from a different time zone to where that block is registered.
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
Rizwan328
Participant
1515 Points
358 Posts
Re: Get users IP address
Nov 10, 2008 02:48 PM|LINK
GeoByte is providing good services like these.......
following link may help you http://www.geobytes.com/GeoDirection.htm
Cheers,
Muhammad Rizwan Javed
Sr. Software Engineer
Dubai, United Arab Emirates
Mick Breen
Member
9 Points
39 Posts
Re: Get users IP address
Nov 14, 2008 01:15 PM|LINK
Good Post but I want to removed the domain and only keep the host name eg
Q1111.xxxxx.xx.xx.xx
I only want Q1111.
My code that returns the Q1111.xxxxx.xx.xx.xx is on page load as follows:
System.Net.IPHostEntry HostIP = new System.Net.IPHostEntry();HostIP = System.Net.Dns.GetHostEntry(Request.ServerVariables["Remote_Host"]);lbl_NetBiosNameDetail.Text = HostIP.HostName;
Can anyone assist?
Mick
TATWORTH
All-Star
72405 Points
14018 Posts
MVP
Re: Get users IP address
Nov 14, 2008 01:26 PM|LINK
I will write you some code for you, once I clarify what you require. You cited Q1111.xxxxx.xx.xx.xx
IP addresses have four components, but you show 5.
However you may like to go to http://www.codeplex.com/IPAddressExtensions and try the IP Extensions project.
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
Mick Breen
Member
9 Points
39 Posts
Re: Get users IP address
Nov 14, 2008 01:37 PM|LINK
This is not the IP Address but the computer name Q1111.
The rest of the xxxx.xxx.xx is the environment.
Mick
TATWORTH
All-Star
72405 Points
14018 Posts
MVP
Re: Get users IP address
Nov 14, 2008 01:58 PM|LINK
Here is the function plus some unit test code
#region " Copyleft "
// Copyright (C) 2008 Clive Chinery
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#endregion
namespace Demo
{
using System;
using NUnit.Framework;
/// <summary>
/// IpAddressTest
/// </summary>
[TestFixture]
public class IpAddressTest
{
/// <summary>
/// Test GetBlock1
/// </summary>
[Test]
public void GetBlock1Test1()
{
Assert.AreEqual("123", GetBlock1("123.111.222.103"));
}
/// <summary>
/// Test GetBlock1
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentException))]
public void GetBlock1Test2()
{
Assert.AreEqual("123", GetBlock1("123.111.222"));
}
/// <summary>
/// Get Block 1
/// </summary>
/// <param name="input">IP Address</param>
/// <returns>Block 1</returns>
public string GetBlock1(string input)
{
var work = (string.Empty + input).Split('.');
if (work.Length != 4)
{
throw new ArgumentException("input is not in form xxx.xxx.xxx.xxx");
}
return work[0];
}
}
}
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