Web Service - How to get ip address of remote client?

  • Thread starter Thread starter runningdog
  • Start date Start date
R

runningdog

Hi

I have a web service written in vb .net and I would like to be able to
record the ip address of clients using the service. Any thoughts would be
appreciated.

TIA Steve
 
Hi Steve,
You can use the context object in a web method to get the remote address.
Get the "remote_addr" property in the ServerVariables collection.

Imports System.Web.Services

<WebService(Description:="Echo Requestor's IP address")> _
Public Class EchoIP
Inherits System.Web.Services.WebService

<WebMethod(description:="Echo Requestor's IP address")
Public Function echo() As String
Return Context.Request.ServerVariables("remote_addr")
End Function
End Class


Best Regards,
Phil Harvey
 
Thanks Phil,

Works fine. Your sample code made implementing it simple

Regards Steve
 
Back
Top