客户端ipaddress在localhost中工作,但在服务器中托管后不工作 [英] the client ipaddress working in localhost but not after hosting in server

查看:44
本文介绍了客户端ipaddress在localhost中工作,但在服务器中托管后不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下:

my code is below:

string myHost = System.Net.Dns.GetHostName();
            System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(myHost);
            foreach (System.Net.IPAddress myIP in myIPs.AddressList)
            {
                TextBox1.Text = myIP.ToString();
            }


请帮助我.....
预先感谢.


please help me.....
Thanks in advance.

推荐答案

好吧,不.您期望什么?当您在服务器上运行它时,它将返回服务器的本地地址-即它在LAN上的网络地址,而不是它在Internet上的地址. DNS服务器将是本地路由器或其他路由器.
Well, no. What did you expect? When you run that on the server, it will return the local address of the server - i.e. it''s network address on the LAN, rather than it''s address on the internet. The DNS server will be the local router or whatever.


这篇关于客户端ipaddress在localhost中工作,但在服务器中托管后不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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