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

1 comment:

Unknown said...

hi Javed..nice to see your blogs..isme contentes ka colur change ker do..visibale nahi hia puri tarah se..