Previously in other version of asp.net, I used these properties of HttpRequest
:
Request.ServerVariables["REMOTE_ADDR"]
Request.UserHostAddress
How can I achieve the same in ASP.NET Core?
Previously in other version of asp.net, I used these properties of HttpRequest
:
Request.ServerVariables["REMOTE_ADDR"]
Request.UserHostAddress
How can I achieve the same in ASP.NET Core?
HttpContext.Connection.RemoteIpAddress
is the property you are looking forAnd you can use Request
You can use
IHttpContextAccessor
:Now you get IP address this way"