3

How can i get the request IP in a RESTfull service using WebOperationContext ( not OperationContext).

Thank you.

(if im way off -or this is not the way to go about it please let me know aswell)

UPDATE: Here's a link to the proper way to do it (as the answer below recommends): WCF 4 Rest Getting IP of Request?

Community
  • 1
  • 1
JanivZ
  • 2,265
  • 3
  • 25
  • 31

1 Answers1

6

If you want to know the IP of the client, then you can't do it via the WebOperationContext (WOC) - you need to get the RemoteEndpointMessageProperty from the "normal" OperationContext. The only thing the WOC will give you is the Host header from the HTTP request (via its IncomingRequest.Headers property).

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
  • 1
    Thanks. Here's a link to what carlos suggested: http://stackoverflow.com/questions/3589110/wcf-4-rest-getting-ip-of-request – JanivZ Nov 10 '11 at 09:53