2016-09-09 62 views
1

我正在使用最新的WCF版本。我收到客户端的IP地址这样的:WCF服务中的客户端IP地址格式

 OperationContext context = OperationContext.Current; 
     MessageProperties prop = context.IncomingMessageProperties; 
     RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; 
     string ip = endpoint.Address; 

的IP我得到的是:

:: 1

是什么意思,有人可以给我解释一下这种格式?

是否因为绑定?我用basicHttpBinding

回答

2

这是IPv6环回地址

https://en.wikipedia.org/wiki/Localhost

即客户端是在同一台机器上,并连接到使用IPv6

+0

感谢的服务,这是有道理的。是否有可能获得客户的IPv4? – chris

+0

碰巧,这是非常接近http://stackoverflow.com/questions/2028879/ipv4-remote-address-in-wcf其中有一些建议 –

+0

我看到了。答案是从2010年开始,它基本上是这样说的 - “我不知道有任何WCF设置来强制执行 - 你必须深入网络堆栈,看看是否有办法使它使用IPv4地址,而不是IPv6“。所以我想知道是否有办法规范一个客户端的IP地址(所以我只会用一种格式记录IP) – chris