Example #1
0
        public IActionResult Index()
        {
            string anAddress = "google.com";
            PingIt p         = new PingIt();

            String      strReturn  = string.Empty;
            Ping        pingSender = new Ping();
            PingOptions options    = new PingOptions();

            options.DontFragment = true;

            // Create a buffer of 32 bytes of data to be transmitted.
            string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

            byte[]    buffer  = Encoding.ASCII.GetBytes(data);
            int       timeout = 120;
            PingReply reply   = pingSender.Send(anAddress, timeout, buffer, options);

            if (reply.Status == IPStatus.Success)
            {
                ViewData["Address"] = reply.Address.ToString();
            }

            return(View());
        }
Example #2
0
        public string Ping(string name)
        {
            PingIt p = new PingIt();

            return(HtmlEncoder.Default.Encode($"Ping {p.PingItStr("ivisibility.com")}"));
        }