Get client system ip address(visitor or user login ip)
i want to get client system ip address, i used some code but it is talking proxy ip address but i want to get client system ip address(User login ip address) pls help me, using asp.net c#
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajender GottipamulaPosted Sep 26, 2019, 5:14 AM
Jaimin ShethiyaPosted Sep 23, 2019, 7:03 AM
You have used this code in you class.
Or refer below link
https://stackoverflow.com/questions/21155352/get-ip-address-of-client-machine
might you have help.
let me know if you have needed any other help.
Thanks
Sai Kumar KoonaPosted Sep 23, 2019, 6:14 AM
RajaPosted Jun 11, 2018, 1:46 AM
Thirunavukkarsu jPosted Jun 18, 2015, 6:59 AM
Thirunavukkarsu jPosted Jun 18, 2015, 6:59 AM
Saroj Kumar SahuPosted Jun 18, 2015, 12:43 AM
Thirunavukkarsu jPosted Jun 17, 2015, 6:30 AM
Upendra Pratap ShahiPosted Jun 17, 2015, 4:52 AM
Khan Abrar AhmedPosted Jun 17, 2015, 3:54 AM
Saroj Kumar SahuPosted Jun 17, 2015, 3:47 AM
Thirunavukkarsu jPosted Jun 17, 2015, 2:27 AM
Thirunavukkarsu jPosted Jun 17, 2015, 2:22 AM
Saroj Kumar SahuPosted Jun 16, 2015, 8:45 AM
UserHostAddressproperties on theRequestobject to get the client IP.Manoj BhoirPosted Jun 16, 2015, 8:37 AM
/// method to get Client ip address
///
/// set to true if want to get local(LAN) Connected ip address
///
public static string GetVisitorIPAddress(bool GetLan = false)
{
string visitorIPAddress = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (String.IsNullOrEmpty(visitorIPAddress))
visitorIPAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
if (string.IsNullOrEmpty(visitorIPAddress))
visitorIPAddress = HttpContext.Current.Request.UserHostAddress;
if (string.IsNullOrEmpty(visitorIPAddress) || visitorIPAddress.Trim() == "::1")
{
GetLan = true;
visitorIPAddress = string.Empty;
}
if (GetLan && string.IsNullOrEmpty(visitorIPAddress))
{
//This is for Local(LAN) Connected ID Address
string stringHostName = Dns.GetHostName();
//Get Ip Host Entry
IPHostEntry ipHostEntries = Dns.GetHostEntry(stringHostName);
//Get Ip Address From The Ip Host Entry Address List
IPAddress[] arrIpAddress = ipHostEntries.AddressList;
try
{
visitorIPAddress = arrIpAddress[arrIpAddress.Length - 2].ToString();
}
catch
{
try
{
visitorIPAddress = arrIpAddress[0].ToString();
}
catch
{
try
{
arrIpAddress = Dns.GetHostAddresses(stringHostName);
visitorIPAddress = arrIpAddress[0].ToString();
}
catch
{
visitorIPAddress = "127.0.0.1";
}
}
}
}
return visitorIPAddress;
}
Thirunavukkarsu jPosted Jun 16, 2015, 8:24 AM
Manoj BhoirPosted Jun 16, 2015, 8:19 AM
Request.ServerVariables("REMOTE_ADDR")
Or