How To Show External IP Address Using C# And WebClient
I experimented a snippet to get my ISP provided IP address using whatismyip. Using tutorials or code snippets from links, the web request just returned a 404 error. After reading the whatismyip API again,they have changed their automation URL. Below is the code snippet.
//previous URL present on most tutorials which is not working //string whatIsMyIp = "http://www.whatismyip.com/automation/n09230945.asp"; //updated URL from whatismyip API string whatIsMyIp = "http://automation.whatismyip.com/n09230945.asp"; WebClient wc = new WebClient(); UTF8Encoding utf8 = new UTF8Encoding(); string requestHtml = ""; requestHtml = utf8.GetString(wc.DownloadData(whatIsMyIp));
Hi,
ReplyDeleteThank you for such kind words. It gives me the motivation to write more articles provide education to the IT community.
:)
nice
ReplyDeleteThanks Chaand Farish.. :-)
ReplyDelete