What is the equivalent in ASP.NET Core of ASP.NET Framework's HttpContext.Request.UserHostAddress
?
I tried this.ActionContext.HttpContext
but cannot find the UserHostAddress
nor the ServerVariables
properties.
If you have access to the HttpContext
, you can get the Local/Remote IpAddress from the Connection
property like so:
var remote = this.HttpContext.Connection.RemoteIpAddress;
var local = this.HttpContext.Connection.LocalIpAddress;