How do you get the IP address of a computer using ASP.net?

Discussion in 'ASP .Net' started by Progman, Mar 31, 2006.

  1. Progman

    Progman Guest

    How do you get the IP address of a computer using ASP.net?


    I tried Request.UserHostAddress and it does not work.

    I get
    Request for the permission of type
    'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    It should be possible, because many web site can show you your ip address.
    Progman, Mar 31, 2006
    #1
    1. Advertising

  2. Progman

    sirfunusa Guest

    You did not read and apply what others have told you. You can never
    rely on getting the ip address anyway. AOL users for example, always
    will show the same IP, since they go through a proxy. What do you hope
    to do with the IP? Hopefully nothing as naive as user personalization
    or similar.

    Create a one-line test.aspx with the following:

    <% Response.Write (Request.ServerVariables("REMOTE_HOST")) %>
    sirfunusa, Mar 31, 2006
    #2
    1. Advertising

  3. Progman

    Mark Rae Guest

    "sirfunusa" <> wrote in message
    news:...

    > What do you hope to do with the IP? Hopefully nothing as
    > naive as user personalization or similar.


    Quite right! Anyone who believes that the the IP address supplied by any
    browser to any server is even *remotely* accurate is seriously deluded...
    Mark Rae, Mar 31, 2006
    #3
  4. Progman

    Guest

    See what I mean?
    , Mar 31, 2006
    #4
  5. Progman

    Progman Guest

    "read and apply what others have told you"

    sorry but nobody told me about anything to do except to try a line of code.
    so nobody told me any instructions. you may be mixed up with another similar
    thread.

    txs for the input about the aol fact.

    the "REMOTE_HOST" wont work.

    I hope to identify the users computer so they dont create multiple accounts.

    "sirfunusa" <> wrote in message
    news:...
    > You did not read and apply what others have told you. You can never
    > rely on getting the ip address anyway. AOL users for example, always
    > will show the same IP, since they go through a proxy. What do you hope
    > to do with the IP? Hopefully nothing as naive as user personalization
    > or similar.
    >
    > Create a one-line test.aspx with the following:
    >
    > <% Response.Write (Request.ServerVariables("REMOTE_HOST")) %>
    >
    Progman, Apr 1, 2006
    #5
  6. Progman

    Mark Rae Guest

    "Progman" <> wrote in message
    news:NlyXf.27305$...

    > I hope to identify the users computer so they dont create multiple
    > accounts.


    LOL! Have you *really* not got it yet...? You can't rely on the IP address
    to identify a computer. For one thing, lots of people are still using
    dial-up, so their IP address is almost 100% *guaranteed* to be different
    every time they connect to the internet - that's what the 'D' in DHCP
    means...

    Also, what's to stop someone from going to their neighbour's house and
    creating another account from there? Or visiting an Internet cafe? Or...?
    Mark Rae, Apr 1, 2006
    #6
  7. Progman

    sirfunusa Guest

    Of course REMOTE_HOST will work. Did you try it? But YOU CANNOT get the
    user's IP address reliably. End of story.
    sirfunusa, Apr 3, 2006
    #7
  8. Progman

    VickZaro Guest

    see my responses

    "Mark Rae" <> wrote in message
    news:...
    > "Progman" <> wrote in message
    > news:NlyXf.27305$...
    >
    >> I hope to identify the users computer so they dont create multiple
    >> accounts.

    >
    > LOL! Have you *really* not got it yet...? You can't rely on the IP address
    > to identify a computer. For one thing, lots of people are still using
    > dial-up, so their IP address is almost 100% *guaranteed* to be different


    but the proportion of people using cable increase and will be soon the
    majority

    > every time they connect to the internet - that's what the 'D' in DHCP
    > means...


    so I will put in the instructions, make sure your system is a same ip
    address
    simple...

    >
    > Also, what's to stop someone from going to their neighbour's house and
    > creating another account from there? Or visiting an Internet cafe? Or...?


    they will have to have a lot of friends to create many accounts. so this
    will be the minority
    VickZaro, Apr 4, 2006
    #8
  9. Progman

    Mark Rae Guest

    "VickZaro" <> wrote in message
    news:TTlYf.43280$...

    > but the proportion of people using cable increase and will be soon the
    > majority


    Even so, the vast majority of residential cable users are on DHCP too...

    >> every time they connect to the internet - that's what the 'D' in DHCP
    >> means...

    >
    > so I will put in the instructions, make sure your system is a same ip
    > address
    > simple...


    ROTLFMAO! OK, then, explain to me just how you will instruct a home user on
    dial-up to use the same IP address every time they connect...
    Mark Rae, Apr 4, 2006
    #9
  10. Progman

    sirfunusa Guest

    You CANNOT do this. You post here, and have received advice from the
    experts. I, for one, wrote a book on the subject. Your path is ill
    advised, and a very poor solution. I would never hire you. Use a
    database, and store usernames and passwords..um...like MOST other
    websites! There is a reason why they do this. Use the authentication
    mechanisms built into .NET
    sirfunusa, Apr 4, 2006
    #10
  11. Progman

    webonomic Guest

    The original thread for this is here:
    http://groups.google.ca/group/micro...r using ASP.net&rnum=2&hl=en#a73ff8a2b1d29038

    Progman, in your first thread, people gave you the answer. I don't
    want to offend you, but if you haven't figured it out, you shouldn't be
    programming. Also, a quick and easy search on Google for "Asp.Net get
    IP address" or something similar will reveal some good results to tell
    you how to get the IP address. What you seem to want is someone to
    write the code for you. Typically these groups provide paths to the
    answer, you have to walk it yourself.

    Now in your second thread you mention "I hope to identify the users
    computer so they dont create multiple accounts. "

    Hopefully peoples responses made sense. It is not programmatically
    possible to stop people from creating multiple accounts. Because
    person A may end up with person B's IP address, if you block IP address
    from making another account, you just stopped person A from creating an
    account because person B already made one.

    You can store a cookie on a person's machine to track them, and then
    check the cookie to see if they signed up already, but most people do
    not allow cookies or just delete them.

    You could search for Macromedia Flash stored objects which can mimic
    cookies and it is harder to delete these. You'll have to talk to a
    Macromedia user group for more info on that.

    Alternatively, you can take a non programming approach and have people
    sign up supply you with there home address and you can "snail mail"
    them a password. (You know, the non-electronic way of mailing someone
    a letter). But then some people have more then one house address they
    could use, so you still can't 100% know if they already have an
    account.

    Using all of these methods together would be your best bet.
    webonomic, Apr 5, 2006
    #11
  12. Progman

    Jerry Guest

    Jerry, Feb 1, 2008
    #12
  13. "Jerry" <> wrote in message
    news:...

    > From
    > http://www.developmentnow.com/g/8_2...he-IP-address-of-a-computer-using-ASP-net.htm


    The opening statement of that article is far more significant than the
    actual code snippet:

    "You did not read and apply what others have told you. You can never rely on
    getting the IP address anyway. AOL users for example, always will show the
    same IP, since they go through a proxy. What do you hope to do with the IP?
    Hopefully nothing as naive as user personalisation or similar."


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Feb 1, 2008
    #13
    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. A. M. G. Solo
    Replies:
    0
    Views:
    529
    A. M. G. Solo
    Jan 13, 2006
  2. =?Utf-8?B?Umlja3kgQ2hhbg==?=

    Get computer name by ip address (specify which DNS)

    =?Utf-8?B?Umlja3kgQ2hhbg==?=, Mar 2, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    3,782
    =?Utf-8?B?Umlja3kgQ2hhbg==?=
    Mar 2, 2005
  3. Raghu Raman
    Replies:
    2
    Views:
    4,628
    Raghu Raman
    May 5, 2005
  4. A. M. G. Solo
    Replies:
    0
    Views:
    780
    A. M. G. Solo
    Jun 8, 2006
  5. Chris
    Replies:
    6
    Views:
    121
    Ben Morrow
    Jan 3, 2004
Loading...

Share This Page