How to find out the host address of the caller of webmethod

by Andrew Jackson 13. October 2009 04:58
On the server inside the webservice method call, you have access to the HttpContext object. Using HttpContext.Current, you have access to a number of objects (including the request object).

From the request object you can find out information, including the host address from which the request comes from.

If you need to map this address to a hostname , you can use UserHostName property instead

' Example web method
<WebMethod()> _
Public Function TestMessage( ) as String

Trace.WriteLine("GetMessage called from : " + HttpContext.Current.Request.UserHostAddress + " " + HttpContext.Current.Request.UserHostName )

Return "Hello"

End Function

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.net | Development | VB.net

Comments

Comments are closed

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About Me

Andrew Jackson

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008,2009 Andrew K. Jackson

RecentComments

Comment RSS