views:

1839

answers:

3

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)

+1  A: 

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.

Kevin Tighe
Do you know how I would be able to get what ever the router reports to me?
arc1880
+1  A: 
HttpContext.Current.Request.UserHostAddress
HttpContext.Current.Request.UserHostName
Shawn Simon
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)
rmeador
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:
Robert C. Barth
ehh i was just trying to give him the most relevant thing i could find
Shawn Simon
+1  A: 

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.

firedfly
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.
arc1880