C#获取外网IP最简单的方法
+展开
-C#
string myip="";
using (System.Net.WebClient wc = new System.Net.WebClient())
{
myip = wc.DownloadString("//ip.asp");
}
MessageBox.Show(str);
using (System.Net.WebClient wc = new System.Net.WebClient())
{
myip = wc.DownloadString("//ip.asp");
}
MessageBox.Show(str);
简单的几行代码,原理很简单,通过访问外部网站,返回你的外部接口IP地址。
ASP文件只做一件事情,返回当前访问者IP。
+展开
-VBScript
function getip()
dim ip
ip =Request.ServerVariables("http_x_forwarded_for")
if ip="" then ip=Request.ServerVariables("remote_addr")
getip=ip
end function
response.write getip()'====
dim ip
ip =Request.ServerVariables("http_x_forwarded_for")
if ip="" then ip=Request.ServerVariables("remote_addr")
getip=ip
end function
response.write getip()'====
加支付宝好友偷能量挖...
原创文章,转载请注明出处:C#获取外网IP最简单的方法