0

Is there any way I can get the client's Hostname or ComputerName/Device ?

I'm using ASP.Net Core MVC.

The purpose of this is to identify if a user is working on a specified machine or not.

  • You can refer to this [link](https://stackoverflow.com/questions/42852574/httprequest-userhostname-in-net-core/68975818#68975818),But in my point of view, It's difficult to get the hostname outside the LAN. – Xinran Shen Apr 20 '22 at 05:32

1 Answers1

0

I tried this one and it works

string hostName = Dns.GetHostEntry(HttpContext.Connection.RemoteIpAddress).HostName;
Mahmoud Hefny
  • 281
  • 3
  • 13