SL在客户端因为安全方面的原因,做了很多限制,直接不能得到,但是可以通过ASPX页面里写代码获取IP地址,然后传给Silverlight。 通过WCF从服务器端获取就可以了。
public class Service1 : IService1 { public string DoWork() { OperationContext operationContext = OperationContext.Current; MessageProperties messageProperties = operationContext.IncomingMessageProperties; RemoteEndpointMessageProperty remoteEndpointProperty = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; return string.Format("Your IP address is {0} and your port is {1}",remoteEndpointProperty.Address, remoteEndpointProperty.Port); } } |
|
来自: Jcstone > 《Silverlight》