【发布时间】:2016-02-16 19:34:04
【问题描述】:
var test1 = HttpContext.Features.Get<IHttpConnectionFeature>();
var test2 = HttpContext.Connection.RemoteIpAddress;
在IISExpress上本地运行应用程序时,这两行正确返回值0:0:1。
当我在 IIS 7.5(在 VM 上运行)上发布应用程序时。 RemoteIpAddress 始终是 null
我正在使用 ASP.Net 5 RC 1。
如何在 ASP.NET 5 应用程序中获取客户端的 IP 地址?
我尝试了以下问题的解决方案,但是我遇到了上述问题:
【问题讨论】:
-
X-Forwarded-For 似乎在 RC1 U1 中默认设置为来自 Answer
标签: asp.net-core asp.net-core-mvc asp.net-core-1.0