473,657 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detect Country C#

Hi,

I need to detect from which Country (City would be great) the user is
connecting.

Is there any free script for doing this in C#?

Thanks

Nov 18 '05 #1
7 7154
"Antoni Massó Mola" <am****@trilium software.com> wrote in message
news:On******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi,

I need to detect from which Country (City would be great) the user is
connecting.

Is there any free script for doing this in C#?


In general, this cannot be done. Although IP address ranges are allocated by
companies, and although a company may have an address, there is nothing
which demands that a given IP address may only be used within the country in
which the registering company is located.

You'd probably be better off asking the user where he or she is located, and
then hope that the user isn't moving between countries.
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #2
There are a number of website who have this service and decect the country
of my IP.

There must be a way to achieve this. I'll search to see if there is a
commercial version.

"John Saunders" <john.saunder s at SurfControl.com > wrote in message
news:OQ******** ********@TK2MSF TNGP12.phx.gbl. ..
"Antoni Massó Mola" <am****@trilium software.com> wrote in message
news:On******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi,

I need to detect from which Country (City would be great) the user is
connecting.

Is there any free script for doing this in C#?
In general, this cannot be done. Although IP address ranges are allocated

by companies, and although a company may have an address, there is nothing
which demands that a given IP address may only be used within the country in which the registering company is located.

You'd probably be better off asking the user where he or she is located, and then hope that the user isn't moving between countries.
--
John Saunders
John.Saunders at SurfControl.com

Nov 18 '05 #3
this.Page.Reque st.UserLanguage s.GetValue(0).T oString() will give you a
language setting, eg en-gb for UK and en-us for the USA, plus many many
more, have a look at TOOLS - OPTIONS - LANGUAGES (button) - ADD (button).

but... this tells you what language the user wants the website to be in, but
in most cases this could be the country, if its for a form you could default
the language based on this value. This is what GOOGLE ect use to redirect
the countries version of the website.

Steve

"Antoni Massó Mola" <am****@trilium software.com> wrote in message
news:On******** ******@TK2MSFTN GP11.phx.gbl...
Hi,

I need to detect from which Country (City would be great) the user is
connecting.

Is there any free script for doing this in C#?

Thanks

Nov 18 '05 #4
"Antoni Massó Mola" <am****@trilium software.com> wrote in message
news:e9******** *******@TK2MSFT NGP09.phx.gbl.. .
There are a number of website who have this service and decect the country
of my IP.

There must be a way to achieve this. I'll search to see if there is a
commercial version.


There are a number of commercial versions which are unable to tell you the
actual country the user is in. This is because IP addresses cannot reliably
be used to tell you the country.

There is nothing in the standards or RFCs which says that there must be a
correspondence between ranges of IP addresses and countries. Any of these
services are simply using a fluke of the registration process - that when
someone registers for a range of IP addresses, an address is recorded, and
that the address contains a country. But this has absolutely nothing to do
with how those IP addresses are distributed, or to which country.

Sorry, but if you need something reliable (perhaps for legal reasons), then
this isn't it.
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #5
Yes, you are correct.

I've only found databases with tons of IP's.
"John Saunders" <john.saunder s at SurfControl.com > wrote in message
news:uo******** *******@TK2MSFT NGP10.phx.gbl.. .
"Antoni Massó Mola" <am****@trilium software.com> wrote in message
news:e9******** *******@TK2MSFT NGP09.phx.gbl.. .
There are a number of website who have this service and decect the country of my IP.

There must be a way to achieve this. I'll search to see if there is a
commercial version.
There are a number of commercial versions which are unable to tell you the
actual country the user is in. This is because IP addresses cannot

reliably be used to tell you the country.

There is nothing in the standards or RFCs which says that there must be a
correspondence between ranges of IP addresses and countries. Any of these
services are simply using a fluke of the registration process - that when
someone registers for a range of IP addresses, an address is recorded, and
that the address contains a country. But this has absolutely nothing to do
with how those IP addresses are distributed, or to which country.

Sorry, but if you need something reliable (perhaps for legal reasons), then this isn't it.
--
John Saunders
John.Saunders at SurfControl.com

Nov 18 '05 #6
Thanks Steve!

"Steve Drake" <St***@NOSPAMDr akey.co.uk> wrote in message
news:eQ******** ********@TK2MSF TNGP09.phx.gbl. ..
this.Page.Reque st.UserLanguage s.GetValue(0).T oString() will give you a
language setting, eg en-gb for UK and en-us for the USA, plus many many
more, have a look at TOOLS - OPTIONS - LANGUAGES (button) - ADD (button).

but... this tells you what language the user wants the website to be in, but in most cases this could be the country, if its for a form you could default the language based on this value. This is what GOOGLE ect use to redirect
the countries version of the website.

Steve

"Antoni Massó Mola" <am****@trilium software.com> wrote in message
news:On******** ******@TK2MSFTN GP11.phx.gbl...
Hi,

I need to detect from which Country (City would be great) the user is
connecting.

Is there any free script for doing this in C#?

Thanks


Nov 18 '05 #7
"Antoni Massó Mola" <am****@trilium software.com> wrote in message
news:%2******** **********@TK2M SFTNGP10.phx.gb l...
Yes, you are correct.

I've only found databases with tons of IP's.
And if these IPs can reliably tell you the country corresponding to the IP
address, then I'll be very surprised.

--
John Saunders
John.Saunders at SurfControl.com
"John Saunders" <john.saunder s at SurfControl.com > wrote in message
news:uo******** *******@TK2MSFT NGP10.phx.gbl.. .
"Antoni Massó Mola" <am****@trilium software.com> wrote in message
news:e9******** *******@TK2MSFT NGP09.phx.gbl.. .
There are a number of website who have this service and decect the country of my IP.

There must be a way to achieve this. I'll search to see if there is a
commercial version.


There are a number of commercial versions which are unable to tell you the actual country the user is in. This is because IP addresses cannot

reliably
be used to tell you the country.

There is nothing in the standards or RFCs which says that there must be a correspondence between ranges of IP addresses and countries. Any of these services are simply using a fluke of the registration process - that when someone registers for a range of IP addresses, an address is recorded, and that the address contains a country. But this has absolutely nothing to do with how those IP addresses are distributed, or to which country.

Sorry, but if you need something reliable (perhaps for legal reasons),

then
this isn't it.
--
John Saunders
John.Saunders at SurfControl.com


Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2417
by: wEEdpEckEr | last post by:
Hi, I'm building my own webstats, and I was wondering if I could detect following things: the screeen resolution (although I believe this is only to be found out through javascript, this sucks, since my stats have to be collected before any output is made) the provider (through the IP?) An example are this stats: http://www.nedstatbasic.net/s?id=710309 The beginning of the 3th column with last 10 visitors is the provider.
6
3999
by: Stephane Belzile | last post by:
Is there a way I can detect in vb.Net the power has switched to a UPS unit in case of power failure? Thanks
32
4273
by: Victor | last post by:
I've been to a few websites where it displays the town, state (if USA), country I'm browsing from. Now, I know that detecting country is easy, but how do you determine the town? What ASP components do this? Thanks, Bill.
3
11822
by: dw | last post by:
stilHello... Is there a way to detect a person's time zone and/or country when they browse to a site? I want to dynamically display controls and labels based on the user's time zone or country.....if possible. thanks - will
13
5758
by: laredotornado | last post by:
Hi, Does anyone have code that detects if a field has been entered in PO Box format? I'm trying to prevent users from entering PO Boxes for shipping addresses. Thanks, - Dave
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.