Here in this post I wrote c# example to get public, external and ISP IP address.
Nameapce Required :-
http://checkip.dyndns.org
Code Example:-
Output:-
This very frequently used code in to track visitor's IP addres.I hope you enjoyed this post. Please comments your feedback and questions.
Nameapce Required :-
using System.Net;
using System.Text.RegularExpressions;
Your request will be going to below site addres and it will return your IP addres. You must be connected with internet.
Code Example:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
namespace DempApp
{
class GetIpAddress
{
static void Main(string[] args)
{
try
{
string externalIP;
Console.WriteLine("\nPlease
wait...");
externalIP = (new WebClient()).DownloadString("http://checkip.dyndns.org/");
externalIP = (new Regex(@"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}")).Matches(externalIP)[0].ToString();
Console.WriteLine("\n Your
public IP address:- {0}", externalIP);
Console.ReadKey();
}
catch
{
Console.WriteLine("please try
Again!");
Console.ReadKey();
}
}
}
}
Output:-
This very frequently used code in to track visitor's IP addres.I hope you enjoyed this post. Please comments your feedback and questions.
No comments:
Post a Comment