A user login, display the logon location (node with rate of 100%)

Recently in a website, but to have a function, is the user login user login location is displayed after,
For example "show three" after logging in, "Hello, your location is Jiangsu Suzhou city", how to
Achieve? Please cattle people give little brother to take a class! Be indebted forever!

Started by Heidi at February 01, 2016 - 9:17 PM

To determine the position according to the client IP

Posted by Harriet at February 15, 2016 - 9:57 PM

Add Web Reference



IpAddressSearchWebService webService = new IpAddressSearchWebService();
string[] strArea = webService.getCountryCityByIp(strIP);
return strArea[1];

Posted by Gerald at February 21, 2016 - 10:09 PM

Get client IP, judgement customer position is good!

Posted by Zoe at February 25, 2016 - 10:20 PM

+1

Posted by York at February 28, 2016 - 10:27 PM

//This is for client IP
string user_IP = "";
if (Request.ServerVariables["HTTP_VIA"] != null)
{
user_IP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
user_IP = Request.ServerVariables["REMOTE_ADDR"].ToString();
}
//Below is the IP interface to the database is converted to the actual address
string url_str = "";
url_str = "http://whois.pconline.com.cn/ip.jsp?ip=" + user_IP;
WebRequest request = WebRequest.Create(url_str);
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);
url_str = reader.ReadToEnd();
reader.Close();
reader.Dispose();
response.Close();
Label1.Text=url_str;//This is to get the position.

Posted by Mariah at March 11, 2016 - 10:50 PM

This interface permanent free.? ?

Posted by Eudora at March 17, 2016 - 11:20 PM

The 2 floor to WebService I spent a long time.

Posted by Anastasia at March 19, 2016 - 11:33 PM

To determine the position according to the client IP

Posted by Jerry at March 26, 2016 - 12:16 AM

First of all thank you for! I tried your code, but the Label1 display is "the machine address" four words. Don't know where is wrong!

Posted by Heidi at November 28, 2016 - 5:57 PM

First of all I thank, specific point but can say? Or multiple point code, let me have a look, brother rookie, also hope to advise!

Posted by Heidi at December 11, 2016 - 6:22 PM


Posted by Gerald at December 26, 2016 - 7:12 PM

I want to click on me useful, click on the wrong
Why do I use to find out the address is "China Mobile".?

Posted by Heidi at January 01, 2017 - 8:04 PM

Put a piece of code. Sina interface:
if (context.Request.ServerVariables["HTTP_VIA"] != null) //Get through the proxy server IP address
{
UserIP = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
UserIP = context.Request.ServerVariables["REMOTE_ADDR"].ToString();
}

string json = new HttpClient("http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=" + UserIP).GetString();
if (StringPlus.IsNotNull(json))
{
JsonData jd = JsonMapper.ToObject(json);
if (jd["ret"].IsInt && (int)jd["ret"] == 1)
{
string province = jd["province"].ToString();
string city = jd["city"].ToString();
string isp = jd["isp"].ToString();
if (province == city)
{
address = province + " " + isp;
}
else
{
address = province + city + " " + isp;
}
}
}

Posted by Cinderella at January 08, 2017 - 8:00 PM

I tried, but the error! Do not know how it is!

Posted by Heidi at January 11, 2017 - 8:51 PM

Well, you have your own IP correspondence table and provinces city. It interfaces you call the third party to do this.
This is nothing to say.

Posted by Adam at January 13, 2017 - 8:59 PM