随着ASP.NET的发展,有不同的方式从请求中访问客户端IP地址.WebForms和MVC Web应用程序只是访问当前HTTP上下文的请求. var ip = HttpContext.Current.Request.UserHostAddress; 或者只是直接引用当前的Request var ip = Request.UserHostAddress; 但是,这在ASP.NET Core 2.0及更高版本中不起作用.您必须从ConfigureServices方法中的Startup.cs类中注入 …
转自:http://www.cnblogs.com/weixing/p/5674078.html References required: HttpContextWrapper - System.Web.dll RemoteEndpointMessageProperty - System.ServiceModel.dll OwinContext - Microsoft.Owin.dll (you will have it already if you use Owin package) usin…