加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

调用根据IP查看城市WebService

发布时间:2020-12-17 00:43:29 所属栏目:安全 来源:网络整理
导读:添加引用:http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx .cs代码 ? //IP查询省市 ??????? protected void BindIP(string strIP) ??????? { ???????????IpAddressSearchWebServiceSoap IpSearch = new IpAddressSearchWebServiceSoa

添加引用:http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx

.cs代码

? //IP查询省市
??????? protected void BindIP(string strIP)
??????? {
???????????IpAddressSearchWebServiceSoap IpSearch = new IpAddressSearchWebServiceSoapClient("IpAddressSearchWebServiceSoap");
??????????? string[] infos = IpSearch.getCountryCityByIp(strIP);
??????????? char[] strcity = { ' ' };
??????????? string[] str = infos[1].ToString().Split(strcity);
??????????? //infos[1] 显示的是全部
??????????? Response.Write("IP是:"+infos[0]+"? IP所在城市是:"+str[0]);??????? }

??????? protected void btnIP_Click(object sender,EventArgs e)
??????? {
??????????? string strip = txtIP.Text;
??????????? BindIP(strip);
??????? }

html代码

?<asp:TextBox ID="txtIP" runat="server"></asp:TextBox> ?<asp:Button ID="btnIP" runat="server" Text="IP查询城市" onclick="btnIP_Click" />

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读