HttpRequest.UserHostAddress gives the IP address of the remote client. In ASP.NET Core 1.0, you need to use the HTTP connection function to get the same thing. HttpContext has a GetFeature<T> method that can be used to get a specific function. For example, if you want to get the remote IP address from the controller action method, you can do something like this.
var connectionFeature = Context .GetFeature<Microsoft.AspNet.HttpFeature.IHttpConnectionFeature>(); if (connectionFeature != null) { string ip = connectionFeature.RemoteIpAddress.ToString(); }
Badri Nov 25 '14 at 17:41 2014-11-25 17:41
source share