asp.net - How to detect visitor country -
to detect visitor country see below code suggested in many forums, cant working.
modglobal.resolvecountry.threeletterisoregionname
on local machine correctly return computer retional settings region whereas on production server return usa.
i guess because function return envoirement regional settings (ie servers regional setting), can confirm this? , if true, best practice detecting visitors country in asp.net?
try this
dictionary<string,string> objdic = new dictionary<string,string>(); foreach (cultureinfo objcultureinfo in cultureinfo.getcultures(culturetypes.specificcultures)) { regioninfo objregioninfo = new regioninfo(objcultureinfo.name); if (!objdic.containskey(objregioninfo.englishname)) { objdic.add(objregioninfo.englishname, objregioninfo.twoletterisoregionname.tolower()); } } var obj = objdic.orderby(p => p.key ); foreach (keyvaluepair<string,string> val in obj) { ddlcountries.items.add(new listitem(val.key, val.value)); }
englishname
return country name
from ip see
Comments
Post a Comment