Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have dropdownlist i want display communication port list of computer i am using mvc with razor plz help me?
XML
public static List<string> GetAllPorts()
   {
      List<string> allPorts = new List<string>();
   
      foreach (String portName in System.IO.Ports.SerialPort.GetPortNames())
      {
          allPorts.Add(portName);
       }
       return allPorts;
    }



i am using this code but not working.
Posted
Updated 10-Jun-14 1:23am
v5
Comments
Kornfeld Eliyahu Peter 10-Jun-14 4:29am    
Communication ports of which computer? The server? The client?
Member 9027346 10-Jun-14 5:12am    
client
[no name] 10-Jun-14 6:45am    
If you want client side information, why are you writing code that will only get server side information?
Richard MacCutchan 10-Jun-14 4:33am    
What does "not working" mean?
Member 9027346 10-Jun-14 5:13am    
port list not coming

1 solution

Me:
Communication ports of which computer? The server? The client?
OP:
client
In that case go back and learn your lessons about web applications from the beginning, but now listen to the teachers!
The code you presented runs on the SERVER machine!!! So in any case you can not list the com ports of the client!!! But for your consolation you can't read com ports from a web page on the client anyway...
Take a free advise - rethink what do you want to do and for what and do not try to write code before you have a design worth of it...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900