测试IP来源:运行—>CMD ——>ping http://www.baidu.com/
操作 步骤
选中你的项目 右键添加web引用: http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx 前往
引用那里改好名字 你需要当做命名空间调用
然后就是下面的代码
图片在附件里面
1
using
GetIP;
//
这个命名空间是在添加引用的时候自己写的
2
IpAddressSearchWebService IpSearch
=
new
IpAddressSearchWebService();
//
IpAddressSearchWebService是添加引用的里面的一个类
3
string
[] infos
=
IpSearch.getCountryCityByIp(
this
.TextBox1.Text);
//
调用getCountryCityByIp返回string数组 第一个为IP 第二个为IP地址的地址
4
Response.Write(
"
你输入的IP是:
"
+
infos[
0
]
+
"
</br>IP地址所在地是:
"
+
infos[
1
]
+
""
);

2

3

4

更多参考: http://www.92dotnet.com/showtopic-470.aspx