all groups > dotnet web services > october 2007 >
You're in the

dotnet web services

group:

Client Information


Client Information Scott Elgram
10/29/2007 1:16:01 PM
dotnet web services:
Hello,
I have a webservice designed in VS 2005 using C#. I would like to know
the URL and the IP addresses of the people who are accessing my service. Is
this a possibility? if so how?

Thanks,
--
-Scott

Re: Client Information Robby Valles
11/1/2007 9:29:32 PM
Scott,

Please try the following in your webservice class.

Context.Request.UserHostAddress

That should be available and what you need. Let me know... email me if
you'd like.

Robby Valles

[quoted text, click to view]

Re: Client Information John Saunders [MVP]
11/3/2007 4:42:25 PM
[quoted text, click to view]

What do you mean, "URL"? What do you mean, "people"? People don't have URLs,
and URLs don't access web services. Please give us more detail.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Re: Client Information Scott
11/8/2007 12:13:29 PM
Ok, in detail...
I have created a WebService in VS 2005 using C# that returns the results
of a database search in an XML dataset .
The purpose is to allow clients access to this webservice so that they
can utilize the search options I make public through the webservice. By
doing it this way clients who use this service should be able to incorporate
my data into their website as if it were their own.
What I am trying to record is the URL of the page that accessed the
webservice and the IP of the domain that page is under.
For example:
The company XYZ.com (IP: 111.111.111.111) would like to use my data
on their website. using the webservice I have created they access the
webservice through code on www.xyz.com/search.aspx which returns an XML
dataset which they can display on their page.
In this example what I would like to record is "www.xyz.com/search.aspx"
and "111.111.111.111".

Let me know if that still doesn't make sense.
Thanks,
-Scott


[quoted text, click to view]

Re: Client Information Scott
11/8/2007 2:18:57 PM
Thanks for your reply and I'm sorry it took so long for me to get back to
this.
I tried what you suggested and I now get the IP address of the site that
is accessing the service. Thank you very much, however, I would also like
to get the name of the page that is calling the service. I tried using
"Context.Request.Url.AbsolutePath" but all I get is the address of the
services asmx file. i.e. /SiteFolder/Service.asmx

if you can offer any info to resolve this as well it would be much
appreciated.

-Scott

[quoted text, click to view]

Re: Client Information John Saunders [MVP]
11/8/2007 6:04:53 PM
[quoted text, click to view]

It makes sense; it's just not practical.

As another poster as indicated, you can get the IP address that accessed the
service. This may or may not correspond to an actual web server. It could
just as easily be the IP address of a NAT box or some other piece of network
equipment.

Picture the classic seven-layer model. IP addresses belong to the Network
layer. This means that the Network layer can do whatever it wants to with an
IP address, as long as it doesn't screw up the Transport layer. In other
words, your code (in the Application Layer) shouldn't be depending on IP
addresses to mean anything at the Application Layer. They are Network Layer
artifacts.

If you want an identifier you can depend on at the Application Layer, you
will need to create one: a certificate, for instance.

You will never get the URL of the page that called the service because pages
don't call services - code does. That code may or may not be on a web page,
and it may or may not know the URL of the web page. That URL might or might
not be useful in locating the page again from a browser's address bar, but
it's not likely to be too useful to use as an identification - consider the
case of a web farm, for instance, or the case where the URL of the page has
nothing to do with the domain of the company (assuming that the company only
owns a single domain).

You go on to mention the IP address of the domain. That term has no meaning.
Domains do not have IP addresses, per se.

All in all, you should just totally forget the idea of the networking
infrastructure doing your job for you. If you need to identify users and/or
the company they work for (or some other licensed entity), then you need to
do that explicitly, with your own code, written to your own requirements,
and not written to the requirements of IP Networking, or of Web Browsing, or
of DNS Domains.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Re: Client Information Scott
11/12/2007 2:15:36 PM
You missed my purpose.
I am not trying to use this information to identify proper usage. Just
simply collecting data of who is using it and when. If the IP address is
that of a NAT box or some other piece of hardware that is fine. The people
that have asked me to get this information realize everything that you have
mentioned and they realize that this information may not always be accurate
or available. That, however, doe snot stop them from wanting to log it.
For arguments sake, lets say the information I am trying to retrieve is
available due to however the client has set up their site. I have managed
to get the IP address but I am still stuck on how I can get the URL. So far
I have only been able to retrieve the address of the ASMX file not whatever
called it.
If you are unable/unwilling to help or if this just simply is not
possible please simply just say so. A lecture on networking and/or coding
may be useful to some, and I'm not saying I don't appreciate your insight,
it does not help me get the info I need or convince the bosses that they
don't want it.


[quoted text, click to view]

Re: Client Information John Saunders [MVP]
11/12/2007 5:41:44 PM
[quoted text, click to view]

Scott, there _is_ no URL. What it the client that called your web service
was not a web page? In that case, there would be no URL to pass, so the web
services infrastructure _never_ passes any URL.

Sorry, but if you want to log the URL of the web page that called the web
service, then you'll have to make the web page pass the URL to the service.
This could be done as a parameter to every web service operation, or it
could be done through a custom SOAP Header.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Re: Client Information Scott
11/12/2007 11:09:57 PM
If the client that called the service is not a page then the variable should
simply be null. But, the main purpose here is so that clients could access
specific functions with the info in our database from a webpage. So
assuming that it is indeed a webpage that calls the web service is there
still no way to get the URL of that page?

[quoted text, click to view]

Re: Client Information John Saunders [MVP]
11/13/2007 10:27:55 AM
[quoted text, click to view]

No. Not unless the page sends it to the service.

Remember that a web service simply receives some XML sent by some code.
There's nothing to indicate whether the code was a page, or which page it
was.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Re: Client Information Scott
11/13/2007 12:57:32 PM
Thanks, I'll have to just be happy woth the IP address then

[quoted text, click to view]

AddThis Social Bookmark Button