Get IP Address of Originating Website From a Webservice
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
Posted on December 30, 2010, in Programming & Development and tagged .net, asp, c#, wcf, web, web application, web service, webservice, website. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0