TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Raja
NA
2k
358.6k
How to find the client public internet IP Address in c#?
Jun 8 2018 5:56 AM
I want the client public ip in c# i have used the below code get the public ip of client but code is getting only hosted server IP only not getting client's public ip how to get the Public ip of client.
https://www.c-sharpcorner.com/blogs/how-to-get-public-ip-address-using-c-sharp1
static
string
GetIPAddress()
{
String address =
"";
WebRequest request = WebRequest.Create(
"http://checkip.dyndns.org/");
using (WebResponse response = request.GetResponse())
using (StreamReader stream =
new
StreamReader(response.GetResponseStream()))
{
address = stream.ReadToEnd();
}
int first = address.IndexOf(
"Address: "
) + 9;
int last = address.LastIndexOf(
"</body>"
);
address = address.Substring(first, last - first);
return address;
}
public string GetIPAddress()
{
try
{
// string address;
address = (new
WebClient()).DownloadString("http://checkip.dyndns.org/");
address = (new Regex(@"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"))
.Matches(address)[0].ToString();
return address;
}
catch { return null; }
}
these code getting only hosted server ip.
Reply
Answers (
3
)
Getting Response error in The SMS GateWay
dropdownlist how can select data