. NET (C #) Call WebService get client IP address zone (non-async)

Source: Internet
Author: User

Function Description:

This interface is used to obtain the IP address to which the client accesses the region (country, city, etc.). Query the country, city, owner and other information by entering the IP address. No country specified for China input parameter: IP address (auto replace). "For". " ), return data: A one-dimensional string array of string (1), string (0) = IP address, string (1) = country, city, owner, etc. 1.1.1. Interface Address WebService Way: Example: http://webservice.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?op= Getcountrycitybyip 1.1.2. Method Name Getcountrycitybyip 1.1.3. Parameter Description request parameter: Parameter name Chinese meaning type required note No 32-bit binary number String is for example: "127.0.0.1" no 32 bits binary numberString is for example: "218.108.242.108" Return Result: Parameter name Chinese meaning type required remarks string[] STRAREA_IP returns an array containing IP information string [] No for example: count=2, which represents an array length of 2 (0,1) strarea_ip[0] client-requested IP address S Tring No for example: "218.108.242.108" strarea_ip[1] IP address region information String No for example: "Hangzhou, Zhejiang"      The following is the IP parameter that is passed in to obtain the region to which it belongs: According to the third party website (WebService provider), to obtain the IP address of the client by crawling the Internet IP address of the computer on this website. Of course, if that day this site changed the domain name or does not exist, this method will not be used properly Oh! The next thing is very simple, add the above webservice to the project, and then call this webservice to get the area of the Internet. The code is specifically implemented as follows:///<summary>///For the area of the Internet IP//</summary>//<returns></ret             Urns> private String Getconnectnetaddressarea () {String StrIP = "218.108.242.108;//The requested IP address             Ipaddresssearchwebservice webService = new Ipaddresssearchwebservice ();             String[] Strarea_ip=webservice.getcountrycitybyip (StrIP); Return strarea_ip[1];//results: "Zhejiang Hangzhou"} Copy Code

. NET (C #) Call WebService get client IP address zone (non-async)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.