URL: http://lite.ip2location.com/

Use the code below to convert the IP address of your web visitors and lookup for their geographical location, e.g. country, state, city, latitude/longitude, ZIPs, timezone and so on. Free database can be downloaded at http://lite.ip2location.com.

Expand | Embed | Plain Text
  1. /// <summary>
  2. /// Convert IPV6 Address to IP Number
  3. /// Free geolocation database can be downloaded at:
  4. /// http://lite.ip2location.com/
  5. /// </summary>
  6.  
  7. string strIP = "2404:6800:4001:805::1006";
  8. System.Net.IPAddress address;
  9. System.Numerics.BigInteger ipnum;
  10.  
  11. if (System.Net.IPAddress.TryParse(strIP, out address)) {
  12. byte[] addrBytes = address.GetAddressBytes();
  13.  
  14. if (System.BitConverter.IsLittleEndian) {
  15. System.Collections.Generic.List<byte> byteList = new System.Collections.Generic.List<byte>(addrBytes);
  16. byteList.Reverse();
  17. addrBytes = byteList.ToArray();
  18. }
  19.  
  20. if (addrBytes.Length > 8) {
  21. //IPv6
  22. ipnum = System.BitConverter.ToUInt64(addrBytes, 8);
  23. ipnum <<= 64;
  24. ipnum += System.BitConverter.ToUInt64(addrBytes, 0);
  25. } else {
  26. //IPv4
  27. ipnum = System.BitConverter.ToUInt32(addrBytes, 0);
  28. }
  29. }

最新文章

  1. NFS Volume Provider(Part II) - 每天5分钟玩转 OpenStack(63)
  2. jeecg表单页面控件权限设置(请先看官方教程,如果能看懂就不用看这里了)
  3. Centos7上启动vpn客户端失败问题处理
  4. AngularJs自定义指令详解(10) - 执行次序
  5. PHP对redis操作详解【转】
  6. http协议.md
  7. javascript继承扩展类方法实现
  8. leveldb
  9. 使用Cygwin通过ssh命令行来访问Windows8
  10. 安卓SDK Manager自动管理各种包
  11. mysql数据库编码
  12. Java学习作业(14.4.21)
  13. boot之mybatis
  14. (一)Java工程化--Maven基础
  15. Linux自制编译内核
  16. #9 //[SDOI2017]新生舞会
  17. 雷林鹏分享:jQuery EasyUI 树形菜单 - 树形网格惰性加载节点
  18. NServiceBus消息重播
  19. Exp9 20155218 Web安全基础实践
  20. 微信小程序——页面之间传递值

热门文章

  1. 阿牛OCX编程助手
  2. C#调用百度地图API经验分享(一)
  3. 【动态规划】bzoj1664 [Usaco2006 Open]County Fair Events 参加节日庆祝
  4. lvs主备可以自由切换,vip落在主上的时候,端口无法telnet,业务连接不了
  5. Android性能优化方法(五)
  6. &quot;2016-10-06T12:09:18.303+0800&quot;
  7. C++函数模版
  8. IPD模式下开展敏捷开发的一些问题汇总
  9. 利用dbms_metadata.get_ddl查看DDL语句
  10. Swift的排序算法总结