The following code was used in a .Net 3.5 web service to retrieve the IP Address of the website consuming it.
This solution may initially escape you since it might seem like the web service should run within an HTTP Context and thus utilize this object to get information from websites calling particular methods.
See MSDN reference(s) for more information.
C#:
RemoteEndpointMessageProperty clientEndpoint = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; clientEndpoint.Address
References:
MSDN, http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.remoteendpointmessageproperty.aspx
Leave a comment