Would you like to react to this message? Create an account in a few clicks or log in to continue.

    Getting an External IP Address

    avatar
    Admin
    Admin


    Posts : 77
    Join date : 2009-07-28

    Getting an External IP Address Empty Getting an External IP Address

    Post  Admin Wed Aug 12, 2009 6:42 pm

    public static void test (){
    WebClient client = new WebClient();

    // Add a user agent header in case the requested URI contains a query.
    client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR1.0.3705;)");

    string baseurl = "http://checkip.dyndns.org/";

    Stream data = client.OpenRead(baseurl);
    StreamReader reader = new StreamReader(data);
    string s = reader.ReadToEnd();
    data.Close();
    reader.Close();
    s = s.Replace("<html><head><title>Current IP Check</title></head><body>", "").Replace("</body></html>", "").ToString();
    MessageBox.Show(s);

    }

      Current date/time is Mon May 20, 2024 10:31 am