How to get Client IP address in ASP.NET Core 2.1

前端 未结 7 679
再見小時候
再見小時候 2021-02-02 09:21

I\'m working on ASP.Net Core 2.1 with Angular Template provided by Microsoft Visual Studio 2017. My Client App is working fine. After competition of User Authentication, I want

相关标签:
7条回答
  • 2021-02-02 10:17

    Try this code,

    var ipAddress = HttpContext.Connection.RemoteIpAddress;

    And if you have another computer in same LAN, try to connect with this pc but use user ip instead of localhost. Otherwise you will get always ::1 result.

    0 讨论(0)
提交回复
热议问题