You can use RemoteAddr to get the remote client's IP address and port (the format is "IP:port"), which is the address of the original requestor or the last proxy (for example a load balancer which lives in front of your server). This is all you have for sure. This is because internally http. Header.
Client IP address can be retrieved via HttpContext. Connection object. This properties exist in both Razor page model and ASP.NET MVC controller. Property RemoteIpAddress is the client IP address.
::1 is the loopback address in IPv6. Think of it as the IPv6 version of 127.0. 0.1 .
One method is to use Request object:
protected void Page_Load(object sender, EventArgs e)
{
lbl1.Text = Request.UserHostAddress;
}
IpAddress=HttpContext.Current.Request.UserHostAddress;
Request.ServerVariables["REMOTE_ADDR"]
To access an index or property on C#, you should use [ ] instead of ( )
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