How Get Client IP. MAC. PC name use wcf4 (tcp/ip mode)

1.8k views Asked by At

I have a wcf service running on LAN server, use tcp/ip mode. Now I need to get every client info when the client send request connect the wcf service. Because it's all on LAN. I just need get the client MAC, IP , PC name. Is there any way to get these info ? thanks.

2

There are 2 answers

1
Alex Barac On BEST ANSWER

http://msdn.microsoft.com/en-us/library/system.environment.machinename(v=vs.110).aspx for computer name

Get public/external IP address? for ip address

Reliable method to get machine's MAC address in C# for MAC

Please consider googleing before posting a question, I found these answers in 2 minutes.

0
Christos On

You could try something like this:

var properties = OperationContext.Current.IncomingMessageProperties;
var endpointProperty = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
if (endpointProperty != null)
{
    var ip = endpointProperty.Address;
}

For more information about OperationContext class, please have a look here.