我们如何获取当前在服务器端运行应用程序的系统的IP地址 [英] How we Get IP Address of the System where our application is currently run on server side

查看:416
本文介绍了我们如何获取当前在服务器端运行应用程序的系统的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private string ip()
    {
        string strHostName = "";
        strHostName = System.Net.Dns.GetHostName();

        IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);

        IPAddress[] addr = ipEntry.AddressList;

        return addr[addr.Length - 1].ToString();
    }




m使用此代码,但返回

"2001:0:4137:9e76:caa:325e:3f57:fe9b"这样的东西

因此,我该怎么做才能获得系统的正确IP地址




m using this code but it return

"2001:0:4137:9e76:caa:325e:3f57:fe9b" somthing like this

So what can i do for to get correct IP Address of the system

推荐答案

那看起来像 ^ ] .


这篇关于我们如何获取当前在服务器端运行应用程序的系统的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆