Showing posts with label IP address. Show all posts
Showing posts with label IP address. Show all posts

Saturday, October 23, 2010

How to get IP address of the client in WCF

Hi folks,
Many times we need to know the IP address of the client machine.
Why? well the simple reason could be to check the IP address for whitelist/blacklist IP ranges.
Here is the answer:

OperationContext objContext = OperationContext.Current;

MessageProperties messageProperties = objContext.IncomingMessageProperties;

RemoteEndpointMessageProperty endpointProperty = (RemoteEndpointMessageProperty

)messageProperties[RemoteEndpointMessageProperty.Name];


Enjoy