Exemplo n.º 1
0
        public ActionResult ip()
        {
            ip  publicip = new ip();
            var client   = new HttpClient();
            var response = client.GetAsync("http://ip-api.com/json");

            response.Wait();
            var result = response.Result;

            if (result.IsSuccessStatusCode)
            {
                var readTask = result.Content.ReadAsStringAsync();
                readTask.Wait();
                ip ip3 = JsonConvert.DeserializeObject <ip>(readTask.Result);
                publicip = ip3;
            }
            string ip = HttpContext.Request.UserHostAddress;

            if (string.IsNullOrEmpty(ip) || ip == "::1")
            {
                string      hostName = Dns.GetHostName();
                IPHostEntry myIP     = Dns.GetHostEntry(hostName);
                IPAddress[] address  = myIP.AddressList;
                ip = address[2].ToString();
            }
            ViewBag.ip    = ip;
            ViewBag.ip2ip = publicip.query;
            ViewBag.ip2c  = publicip.country;
            ViewBag.ip2s  = publicip.regionName;
            ViewBag.ip2ci = publicip.city;
            ViewBag.ip2z  = publicip.zip;
            return(PartialView("ip"));
        }
Exemplo n.º 2
0
 public HttpServer(IPAddress ip, int port) => m_Listener = new TcpListener(ip, port);
Exemplo n.º 3
0
 => _repo = new RemoteRepository(ip, port);
 LoggingFactory.GetLogger().Debug(ip, message);
Exemplo n.º 5
0
 var(ip, acc) = state;