There are techniques to resolve the contry of origin of the IP address. I've seen them for both
PHP & ASP. I seem to remember they both use a CSV file derived from somewhere else. The CSV file is provided form a third party, and isnt always as up todate as it could be. However that does mean you could use another mechanism to derive the IP address included PERL, JAVA or whatever.
There is also a problem where some ISP's register all IP address in a specific country. IE you may be getting an IP Address which indicates its form one country, but instead from another physical location. I think AOL was the main offender but there are others.