Keyvan Nayyeri wrote a blog post a while ago about how to gather the remote IP from remote WCF connections. I wrote an extension method based on his code:
public static RemoteEndpointMessageProperty GetRemoteEndpoint(this OperationContext oc)
{
if (oc == null)
throw new NullReferenceException();
object v;
if (!oc.IncomingMessageProperties.TryGetValue(RemoteEndpointMessageProperty.Name, out v))
return null;
return v as RemoteEndpointMessageProperty;
}
Unfortunately it does not seem to work with the WCF implementation of Silverlight 3 :( .
Q: http://nayyeri.net/detect-client-ip-in-wcf-3-5
UPDATE: Switched to TryGetValue()