title: How to get client IP address in a one-way ASMX Web Service
body: <p>I have a web service that is configured as one way. Or rather, the SoapDocumentMethod attribute has a property that is called "OneWay". That is set to true.</p>
  
  <p>I'm trying to get the IP address of the client request. I get the fact that I won't get the exact IP address because the client may be behind other networking concepts. That's irrelevant. I want an IP address of whoever initiated the call on the service, so if that's some front end server sitting on top of some clients machine, so be it.</p>
  
  <p>I tried using HttpContext, but that doesn't seem to work. If I hit my web service on the same machine as the web service is running, then HttpContext is populated and I can get the IP address. However, any external use of my web service and the HttpContext is a little messed up. It throws exceptions on many of the properties when trying to find out information on the request. So I cannot get the client IP address. If you enable tracing of the service, It then starts working. But that's only a temporary work around. It's not an acceptable solution.</p>
  
  <p>So.. what's the best way to get the client IP address when you have a one way web service?</p>
  
  <p>I've already looked here:
  <a href="http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapdocumentmethodattribute.oneway.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapdocumentmethodattribute.oneway.aspx</a></p>