arc1880
arc1880

Reputation: 519

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)

Upvotes: 1

Views: 7889

Answers (3)

firedfly
firedfly

Reputation: 2369

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.

Upvotes: 1

Shawn
Shawn

Reputation: 19793

HttpContext.Current.Request.UserHostAddress
HttpContext.Current.Request.UserHostName

Upvotes: 5

Kevin Tighe
Kevin Tighe

Reputation: 21161

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.

Upvotes: 2

Related Questions