locked
How to get the client computer name in c# RRS feed

  • Question

  • Hi i need to know how to get the client computer name in c#
    Wednesday, March 10, 2010 6:34 AM

Answers

  • hai..

    Use the following code which will return the Client machine name on which your application is running 

     

    string myHostName = System.Net.Dns.GetHostName();

    Regards

    Sangeetha

    • Marked as answer by Jing0 Friday, March 19, 2010 7:27 AM
    Friday, March 19, 2010 5:48 AM

All replies

  • Hi

    Use this

    My.Computer .Name

    It gets the computer name
    Thanks Avinash Desai
    Wednesday, March 10, 2010 6:55 AM
  • can u give the full coding???????c# can run client side code?
    Wednesday, March 10, 2010 7:01 AM
  • Hi this is the full coding

    Use the My.Computer.Name which returns the Computer name

    Like

    Dim Value as String=My.Computer .Name

    I hope this helps you
    Thanks Avinash Desai
    Wednesday, March 10, 2010 7:04 AM
  • I have one doubt can we run the c# coding in client side?????
    Wednesday, March 10, 2010 7:19 AM
  •  

    You can also get the name of current PC which is running this application by Environment.MachineName property.

     
    Best regards,

    Ling Wang


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Edited by Jing0 Friday, March 19, 2010 5:58 AM correct my reply
    Thursday, March 18, 2010 10:19 AM
  • hai..

    Use the following code which will return the Client machine name on which your application is running 

     

    string myHostName = System.Net.Dns.GetHostName();

    Regards

    Sangeetha

    • Marked as answer by Jing0 Friday, March 19, 2010 7:27 AM
    Friday, March 19, 2010 5:48 AM
  • using

    System;

    using

    System.Windows.Forms;

     

    namespace

    system_information

    {

     

    public partial class Form1 : Form

    {

     

    public Form1()

    {

    InitializeComponent();

    }

     

    private void button1_Click(object sender, System.EventArgs e)

    {

     

    string myHostName = System.Net.Dns.GetHostName();

     

    MessageBox.Show(myHostName);

    }

    }

    }

    Friday, September 24, 2010 8:25 AM
  • Hi

    try this

    string

     

    PCName = Dns.GetHostEntry(Request.ServerVariables["REMOTE_ADDR"

    ]).HostName;

    but if you want Name of Host PC

    string HostPCName = Dns.GetHostName();

    Regards

    • Proposed as answer by Karim.Tahawy Tuesday, September 6, 2011 11:34 AM
    Tuesday, September 6, 2011 11:33 AM
  • Hi Karim, 

    I know that this is and old topic, but im facing the same issue, and neither of the solutions works for me. I always get the SERVER NAME. Is there any way to retrieve the Client Machine Name.

    Regards, 

    Gabriel

    Thursday, March 7, 2013 8:37 PM