2016-10-23 7 views
0

私はウェブサイトを持っています。ユーザーは管理者にメッセージを送信できます。自分のIPアドレスを使用してユーザーの国と都市を知りたいですか?どのようにIPアドレスで国と都市を知ることができますか?

私の問題は、私は、サーバー上の私のウェブサイトを公開すると、すべてのユーザーがメッセージを送信するときに、私の機能は別の場所にあるすべてのユーザーに同じIPアドレスを選択し、別のIPアドレスと、この私のコードを持って開始します。

public string getPublicIP()   
    { 
     string direction; 

     WebRequest request =WebRequest.Create("http://checkip.dyndns.org/"); 

     WebResponse response = request.GetResponse(); 

    StreamReader stream = new StreamReader(response.GetResponseStream()); 

     direction = stream.ReadToEnd(); 

     stream.Close(); 

     response.Close(); 

     int first = direction.IndexOf("Address: ") + 9; 

     int last = direction.LastIndexOf(""); 

     direction = direction.Substring(first, last - first); 

     return direction. 

     Replace("<html><head><title>Current IP Check</title></head> 

     <body>Current IP Address: ", string.Empty). 

     Replace("</body></html>", string.Empty); 

    } 

答えて

0

IPアドレスとそのIPアドレスまたはサイトに入力されたその他のIPアドレスに関連付けられた市区町村、州または国を表示するオンラインサービスがいくつかあります。

関連する問題