asp .net mvc 获得用户IP

it2022-06-26  98

string strHostName = System.Net.Dns.GetHostName(); //clientIPAddress是一个数组,可能有多个数据 var clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName); string clientip = clientIPAddress.GetValue(0).ToString();

示例代码

https://github.com/zLulus/NotePractice/blob/dev3/Website/DotNetFramework/NotePractice/Controllers/ClientInfoController.cs

参考资料

https://www.c-sharpcorner.com/uploadfile/krishnasarala/find-client-ip-address-and-location-in-Asp-Net/

转载于:https://www.cnblogs.com/Lulus/p/9741745.html


最新回复(0)