views:

146

answers:

4

I have developed a web service and host it on my server and I would like to know who is using this web service (site Url). I tryed to use "Request.UrlReferrer" but it is not returning any thing! any suggestions/Advices?

A: 

You can use Request.Url property to get all the information about the requests to your web service.

Kirtan
That would just return the Url of the webservice itself, but no information about the caller.
Zhaph - Ben Duguid
A: 

The referrer is set by the client, and the client can not set it. That is why you see nothing. If the client's are servers, then the best you can do is to get the IP of the client connection and go to that IP. If a simple setup, with no virtual hosts, then that is the "web site" that is hitting your web service.

Stu Thompson
+2  A: 

You can't get the URL of the caller of a web service as not all callers have canonical URL's. You can however get the IP Addresses assuming that they are not behind a proxy / nat. In which case you'd get the IP of the nat / proxy.

Assuming your using an ASMX web service you can this from:

HttpContext.Current.Request.UserHostAddress

Once you have the IP Address you can try and do a reverse lookup to get the host name. I would recommend storing the IP address then writting an offline process which goes and tries to determine who owns the IP. I'm sure there are some webservices out there to help with this.

JoshBerke
"You can't get the URL of the caller of a web service as not all callers have canonical URL's."absolutely right, thanks
Khaled Musaied
Welcome good luck
JoshBerke
A: 

As Josh states, the HttpRequest object is the way to go, there are a few properties on there that might help:

  1. UserHostName - Gets the DNS name of the remote client.
  2. UserAgent - Gets the raw user agent string of the client browser.
  3. UserHostAddress - Gets the IP host address of the remote client.

Which might give you a bit more information to play with.

Zhaph - Ben Duguid