Get location of client machine using ip address
<p>I am trying to get the location of client machine using ip address. Client can access the internet only if
he/she provide the proxy authenication.
Let us say client need to access the 'www.google.com' on the browser then immediately Authenication Required
prompt window open and then client enter his/her username and password. But it is possible the few users does 
not required the provide the authenication in order to access internet.</p>

<p>This segment of code does not helped me...</p>

<pre><code>string url = "http://freegeoip.net/xml/";
WebClient wc = new WebClient();

WebProxy proxyObj = new WebProxy("http://freegeoip.net/xml/");
proxyObj.Credentials = CredentialCache.DefaultCredentials;

Uri uri = new Uri(url);
MemoryStream ms = new MemoryStream(wc.DownloadData(uri));
XmlTextReader rdr = new XmlTextReader(url);
XmlDocument doc = new XmlDocument();
ms.Position = 0;
doc.Load(ms);
ms.Dispose();
</code></pre>

<p>In the above code if i add network credential instance with username, password and domain then it's work perfectly
Instead of providing the default net credential in code itself, I need to get the username and password from the users(client
machine).</p>

<p>My question is how to prompt the Authentication Required Window and get the username and password to load the download from url
I would be glad if someone throw light on this issue...</p>

<p>Edit: Somehow basic authentication window prompt and now i can get the username and password which can use for credential</p>

<pre><code>try
        {
             var reg = HttpContext.Current.Request;


             if (!String.IsNullOrEmpty(reg.Headers["Authorization"]))
             {
                 var cred = System.Text.ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(Request.Headers["Authorization"].Substring(6))).Split(':');
                 var user = new { Name = cred[0], Pass = cred[1] };
                 string url = "http://freegeoip.net/xml/";
                 WebClient wc = new WebClient();
                 WebProxy wProxy = new WebProxy();
                 ICredentials crd;

                 crd = new NetworkCredential("'" + cred[0] + "'", "'" + cred[1] + "'");

                 wProxy = new WebProxy("myproxy", true, null, crd);

                 wc.Proxy = wProxy;

                 Uri uri = new Uri(url);
                 string content = wc.DownloadString(uri);

             }
             else
             {
                 try
                 {

                     //var reg = HttpContext.Current.Request;
                     if (String.IsNullOrEmpty(reg.Headers["Authorization"]))
                     {
                         var res = HttpContext.Current.Response;
                         res.StatusCode = 401;
                         res.AddHeader("WWW-Authenticate", "Basic realm = \"freegeoip\"");
                         //res.End();
                     }
                 }
                 catch (Exception ex)
                 {

                 }
             }

        }
        catch(Exception ex)
        {

        }
</code></pre>

<p>But Still It throwing the "Unable to connect to the remote server"</p>
