C# ASP .NET (VS2005) - how to obtain caller's IP address

Discussion in 'ASP .Net Web Services' started by j.a. harriman, Mar 15, 2007.

  1. Hi,
    Can someone point me to an MSDN or other location where I can obtain the
    caller's IP Address?

    I'd like to put this in the "WebMethod" portion of the program.

    The intent is not so much for security, as it is for me to identify
    customers, and do not want to rely on them putting an "identity" in the
    message to the service.

    Thanks. Jeff
    j.a. harriman, Mar 15, 2007
    #1
    1. Advertising

  2. "j.a. harriman" <> wrote in message
    news:...
    > Hi,
    > Can someone point me to an MSDN or other location where I can obtain the
    > caller's IP Address?
    >
    > I'd like to put this in the "WebMethod" portion of the program.
    >
    > The intent is not so much for security, as it is for me to identify
    > customers, and do not want to rely on them putting an "identity" in the
    > message to the service.


    If your customer is behind any sort of proxy or firewall, you'll get the
    address of the proxy or firewall, and not the client machine. You can't rely
    in the IP address for anything.

    John
    John Saunders, Mar 15, 2007
    #2
    1. Advertising

  3. Other than having them insert something in the request, do you have any other
    thoughts on this that I might be able to look at?
    Thanks.

    "John Saunders" wrote:

    > "j.a. harriman" <> wrote in message
    > news:...
    > > Hi,
    > > Can someone point me to an MSDN or other location where I can obtain the
    > > caller's IP Address?
    > >
    > > I'd like to put this in the "WebMethod" portion of the program.
    > >
    > > The intent is not so much for security, as it is for me to identify
    > > customers, and do not want to rely on them putting an "identity" in the
    > > message to the service.

    >
    > If your customer is behind any sort of proxy or firewall, you'll get the
    > address of the proxy or firewall, and not the client machine. You can't rely
    > in the IP address for anything.
    >
    > John
    >
    >
    >
    j.a. harriman, Mar 15, 2007
    #3
  4. "j.a. harriman" <> wrote in message
    news:...
    > Other than having them insert something in the request, do you have any
    > other
    > thoughts on this that I might be able to look at?


    It depends on what you're trying to do. For instance, how certain do you
    need to be that the request is from one of your customers? Is this some form
    of authentication?

    You might consider having the customer include some data signed via XML
    Digital Signature. This data would be signed in such a way that if you are
    able to verify the signature, it will imply that only your customer could
    have signed it. .NET 2.0 includes the new SignedXml class in the
    System.Security.Cryptography.Xml namespace. It makes it much easier to
    generate and verify digital signatures.

    Basically, the network isn't going to do this job for you. Speaking at a
    somewhat network-theoretical level, your desire to identify your customer is
    pretty much an Application-layer function. That means that it's something
    between your Application and the customer's Application. You can't depend on
    something from the Network layer to do this for you. The Network layer has
    the right to do anything it wants with Network-layer data like the IP
    Address.

    So, if _you_ want to be certain who _your_ customer is, then _you_ have to
    do it.

    John
    John Saunders, Mar 15, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. marco

    how to obtain its ip address ?

    marco, Jun 23, 2004, in forum: Python
    Replies:
    6
    Views:
    421
    Michele Simionato
    Jun 24, 2004
  2. Replies:
    4
    Views:
    737
  3. Matt Savigear
    Replies:
    0
    Views:
    132
    Matt Savigear
    Sep 2, 2009
  4. Mark
    Replies:
    2
    Views:
    391
  5. Ilias Lazaridis

    Obtain Filename and Lineno of the Function Caller

    Ilias Lazaridis, Jun 6, 2007, in forum: Perl Misc
    Replies:
    3
    Views:
    109
    Ilias Lazaridis
    Jun 7, 2007
Loading...

Share This Page