how to get a client IP address in ASP.NET 3.1 when writing code in Web API project
Determining IP Address using $_SERVER Variable Method : There is another way to get the IP Address by using the $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] variables. The variable in the $_SERVER array is created by the web server such as apache and those can be used in PHP.
The simple answer is that: ::1 is the compressed format of IPV6 loopback address 0:0:0:0:0:0:0:1 . It is the equivalent of the IPV4 address 127.0.
Client IP means proprietary systems, software, information, logos, services names, domain names, marks and copyrights the Client uses.
HTTP_X_FORWARDED_FOR is often used to detect the client IP address, but without any additional checks, this can lead to security issues, especially when this IP is later used for authentication or in SQL queries without sanitization.
Use this tutorial. wish it will help you. Get client IP address in Asp.NET core 3
Or just use this line of code in your controller:
var ip =HttpContext.Connection.RemoteIpAddress.ToString()
string ipAddress = HttpContext.Connection.RemoteIpAddress.ToString();
deviceName = Dns.GetHostEntry(HttpContext.Connection.RemoteIpAddress).HostName;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With