Sunday, March 27, 2011

How to retrieve PC name of client from C# webservice

I have a C# web service running on a separate server machine. I would like to be able to retrieve the client machine name when using a specific method on the web service. I have searched online and people have mentioned that this would be difficult to retrieve client machine names if the clients were connected to a router.

Update: If there is no way to get around the router issue, how would I be able to get the client's information (e.i. ip address, machine name, .... anything)

From stackoverflow
  • I don't think this is really possible. If the user is behind a router all you're going to get is whatever the router reports.

    arc1880 : Do you know how I would be able to get what ever the router reports to me?
  • HttpContext.Current.Request.UserHostAddress
    HttpContext.Current.Request.UserHostName
    
    rmeador : while this seems like it would work, I'm pretty sure the host name is not going to be the same as the windows machine name (which is some crazy thing microsoft made up and not part of a standard, unless you count SMB as a standard)
    Robert C. Barth : Crazy? Microsoft made up? It's just the same ole stuff that Netware was doing. It's the LAN name of the machine, before TCP/IP was ubiquitous. How odd that MS would want their LAN networking stack to be able to have a human-readable name for a computer. :rolleyes:
    Shawn Simon : ehh i was just trying to give him the most relevant thing i could find
  • I don't know of a way to retrieve the client PC name from the web service. However, you could send the name as a parameter to your web service. We send the value of Environment.MachineName as a parameter to one of our web services. This will make the information available on in the web service.

    Of course, we only have our WinForms client accessing the web service. You may not be able to do the same thing.

    arc1880 : I currently have a separate web method that does this, but I was trying to see if anyone had a solution or idea on how. It looks like I will have to change the schema in order to make this work. Thanks for the help.

0 comments:

Post a Comment