本文介绍了如何获取客户端IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI全部



当我在本地主机上运行我的asp.net网络应用程序时,我可以获得本地系统IP地址



i我的结果为IP地址::: 1是否正确





谢谢提前

HI all

can i get the local system ip address when i am running my asp.net web application on local host

i am getting my result as "IP Address: ::1" is it correct or not


thank's in advance

推荐答案


string ip=Server.HtmlEncode(Request.UserHostAddress);





这行代码在localhost上执行时会给你类似127.0.0.1的内容。但是假设你主持它生产服务器,那时它将为您提供实际的客户端IP(字符串格式),即尝试与您的网络交互等。



This line of code,when executed on localhost,will give you something like 127.0.0.1.But suppose you host it on production server,at that time it will give you the actual client ip(in string format),that is the one trying to interact with your web etc.



这篇关于如何获取客户端IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:38
查看更多