我在LAN服务器上运行wcf服务,使用tcp / ip模式。 现在,当客户端发送请求连接wcf服务时,我需要获取每个客户端信息。 因为它全部在局域网上。我只需要获取客户端MAC,IP,PC名称。 有没有办法获得这些信息?感谢。
答案 0 :(得分:0)
您可以尝试这样的事情:
var properties = OperationContext.Current.IncomingMessageProperties;
var endpointProperty = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
if (endpointProperty != null)
{
var ip = endpointProperty.Address;
}
有关OperationContext
课程的详情,请查看here。
答案 1 :(得分:-2)
http://msdn.microsoft.com/en-us/library/system.environment.machinename(v=vs.110).aspx代表计算机名称
Get public/external IP address?用于IP地址
MAC的Reliable method to get machine's MAC address in C#
在发布问题之前请考虑谷歌搜索,我在2分钟内找到了这些答案。