2016-08-02 28 views
2

Ich entwickle eine Web-Anwendung in MVC. Wenn sich der Benutzer auf der Website anmeldet, erhalte ich die lokale IP-Adresse des Benutzers. Aber was ich jetzt tun möchte, ist Liste der offenen Ports des lokalen Client-Computers zu scannen.Wie scannt man den offenen Port des Client-Rechners mit der lokalen IP-Adresse in C# in MVC?

Gibt es eine Möglichkeit, dies in JavaScript oder jQuery oder C# in MVC zu implementieren?

+1

Was würden Sie zuerst versuchen, zu tun? Welche Dokumentation, Tutorial oder Beispiel haben Sie konsultieren "Wo steckst du fest? Wie sieht der relevante Teil deines Codes aus, wenn es einen gibt?" – Julian

Antwort

0
public void btnPing_Click(object sender, EventArgs e) 
    { 
     try 
     { 
      int intCount = 0; 
      int maxip = 0; 
      richTmp.Clear(); 
      string strIP = null; 
      string machineName = string.Empty; 
      List<string> strListIp = new List<string>(); 
      List<string> txtBuffrFile = new List<string>(); 
      BufferdIp = new List<string>(); 

      for (int i = 1; i <= 30; i++) 
      { 
       System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping(); 
       lstDetails.Items.Add("System Found: " + maxip); 
       System.Net.NetworkInformation.PingReply rep = p.Send("192.168.1." + i,500); 
       if (rep.Status == System.Net.NetworkInformation.IPStatus.Success) 
       { 
        intCount++; 
        lstDetails.Items.Clear(); 
        lstDetails.Items.Add("Loading...Total(" + maxip+")"); 
        strIP = rep.Address.ToString(); 
        machineName = GetMachineNameFromIPAddress(strIP); 
        if (machineName == string.Empty || machineName == null) 
        { 
         strListIp.Add(strIP + ":-" + "Offline"); 
         BufferdIp.Add("0"); 
        } 
        else 
        { 
         strListIp.Add(strIP + ":-" + machineName+"(Online)"); 
         BufferdIp.Add(strIP); 
         txtBuffrFile.Add(strIP); 
         maxip++; 
        } 
       } 

      } 
      lstDetails.Items.Clear(); 
      foreach (var IDAddres in strListIp) 
      { 
       lstDetails.Items.Add(IDAddres); 
      } 
      for (int i = 0; i != txtBuffrFile.Count;i++) 
      { 
       richTmp.Text += txtBuffrFile.ElementAt(i) + "\n"; 
      } 
      if (MessageBox.Show("Do you want to Save This Search", "Save Dialog", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == (DialogResult.Yes)) 
      { 
       if(File.Exists (path)) 
       File.Delete(path); 
       FileStream stream = File.Create(path); 
       stream.Close(); 
       File.WriteAllText(path, richTmp.Text, Encoding.UTF8); 

      } 
      btnConnct.Enabled = true; 
     } 
     catch (Exception ex) 
     { 
      MessageBox.Show(ex.ToString()); 
     } 
    } 

ich dies in meinem LAN-Bereich ping aber Problem ist dies nur funktioniert, wenn Sie IP-Muster und Range wissen :(