【发布时间】:2019-12-07 10:57:09
【问题描述】:
我在 asp.net core 2.2 中创建了一个微服务应用程序。我想从他使用它的地方获取用户的 IP 地址。
下面的 sn -p 提供了托管服务器的 ip 地址。
var remoteIpAddress = request.HttpContext.Connection.RemoteIpAddress;
我想获取使用 API 进行审核日志的用户的 IP 地址。
【问题讨论】:
-
我认为您必须将其从客户端传递到服务器(Web api)
-
如果您在同一台机器上托管 web api 并调用 web api,那么您将看到与
request.HttpContext.Connection.RemoteIpAddress相同的 IP 地址。 -
@JohnB 能否提供步骤或示例?
标签: c# asp.net-core dependency-injection microservices asp.net-core-webapi