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

前端 未结 7 685
再見小時候
再見小時候 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条回答
  •  梦毁少年i
    2021-02-02 09:56

    After spending some time on searching I found my own question answer. Here I'm also sharing the source link from where I can get my answer and detail explanation for how to query a server to obtain the family addresses and the IP addresses it supports.

    Code:

    IPHostEntry heserver = Dns.GetHostEntry(Dns.GetHostName());
    var ip = heserver.AddressList[2].ToString();
    

    Source

    Here is my another Question: How to access server variables in ASP.Net Core 2.x Hope this helps for you all.

提交回复
热议问题