Visitor's IP Address

Discussion in 'ASP .Net Web Controls' started by Morris Neuman, Jun 30, 2009.

  1. Hi,
    I have a textbox fields on an aspx page that the user fills in then when
    they click on submit the fields get emailed to me.

    How do I get the user's IP address? I don't have any sign-in requirements.

    --
    Thanks
    Morris

    -----------------------------------------------------------------------------
    Less Spam Better enjoyable experience
    Visit : news://spacesst.com
    Morris Neuman, Jun 30, 2009
    #1
    1. Advertising

  2. Hi Morris,

    >I have a textbox fields on an aspx page that the user fills in then when
    >they click on submit the fields get emailed to me.


    >How do I get the user's IP address? I don't have any sign-in requirements.


    To get a client IP usually we can use Request.UserHostAddress. However, if
    the client is under a proxy the IP got by Request.UserHostAddress probably
    is not the real one of the client.

    For some proxies you probably can check
    Request.ServerVariables["HTTP_X_FORWARDED_FOR"]. If it's not null it
    contains the IP of client.

    For other proxies that intentionally hide the IP of client it's hard to
    know the real IP of client. A possible solution is to use ActiveX.

    I have a question BTW. Why you need to know client's IP to send email?

    Regards,
    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 2 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions. Issues of this
    nature are best handled working with a dedicated Microsoft Support Engineer
    by contacting Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.




    -----------------------------------------------------------------------------
    Less Spam Better enjoyable experience
    Visit : news://spacesst.com
    Allen Chen [MSFT], Jun 30, 2009
    #2
    1. Advertising

  3. Hi,

    I don't need the IP to send the email. I have a page with fields(name,
    phone, email, etc) that the user fills then clicks submit to download our
    demo. This sends me an email with the data from the fields. Normally the
    user does not enter the data (we do not force them to) so automatically
    getting their IP or Remote Host I can see if there were duplicate requests,
    etc. My previous website using front page I was able to get this field and
    hoping I can get similar data from my new asp.net website.

    Your suggestion would be appreciated.

    --
    Thanks for your help.
    Morris


    "Allen Chen [MSFT]" wrote:

    > Hi Morris,
    >
    > >I have a textbox fields on an aspx page that the user fills in then when
    > >they click on submit the fields get emailed to me.

    >
    > >How do I get the user's IP address? I don't have any sign-in requirements.

    >
    > To get a client IP usually we can use Request.UserHostAddress. However, if
    > the client is under a proxy the IP got by Request.UserHostAddress probably
    > is not the real one of the client.
    >
    > For some proxies you probably can check
    > Request.ServerVariables["HTTP_X_FORWARDED_FOR"]. If it's not null it
    > contains the IP of client.
    >
    > For other proxies that intentionally hide the IP of client it's hard to
    > know the real IP of client. A possible solution is to use ActiveX.
    >
    > I have a question BTW. Why you need to know client's IP to send email?
    >
    > Regards,
    > Allen Chen
    > Microsoft Online Support
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the support we provide to you. Please
    > feel free to let my manager know what you think of the level of service
    > provided. You can send feedback directly to my manager at:
    > .
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
    >
    > Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 2 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions. Issues of this
    > nature are best handled working with a dedicated Microsoft Support Engineer
    > by contacting Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    > ==================================================
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    >
    >
    Morris Neuman, Jun 30, 2009
    #3
  4. Hi Morris,

    >I don't need the IP to send the email. I have a page with fields(name,
    >phone, email, etc) that the user fills then clicks submit to download our
    >demo. This sends me an email with the data from the fields. Normally the
    >user does not enter the data (we do not force them to) so automatically
    >getting their IP or Remote Host I can see if there were duplicate

    requests,
    >etc. My previous website using front page I was able to get this field

    and
    >hoping I can get similar data from my new asp.net website.


    From your description you want to restrict a user to download a file only
    once, right? If so you have several options:

    1. Check user's IP. The way to do so in ASP.NET is mentioned in my previous
    post. Please note, due to the existing of proxy, the IP you get may not be
    the real one of client. In addition, the way to bind to client's IP doesn't
    mean one user can only download a file only once. User's IP may change in
    many cases, such as accessing to the internet by dialing ISP to request for
    IP.


    2. Check the MAC of network adapter of user's machine. This option is
    better than checking IP because in most cases changing network adapter is
    much more expensive. You can also check other hardware related information.
    However, the difficulty is, we cannot get these information directly at
    server side. To get these information we have to use client side techniques
    such as ActiveX. At last, a user can still download a file twice if he uses
    another computer to access your web page.

    3. Let a user send you his identity. In your case you've already let him
    send his phone number, etc. If you could force him to do so his identity
    can be used to check duplicate request. This is the weakest way because a
    user can cheat you by sending fake identity.

    In a word, there's no perfect way to restrict this. I think option 1 and 3
    are the easiest way. It can help to avoid duplicate download request to
    some extent. You can use the code in my previous code to check it. If you
    have any further questions, please don't hesitate to ask.


    Regards,
    Allen Chen
    Microsoft Online Support
    Allen Chen [MSFT], Jul 1, 2009
    #4
  5. Thanks.

    I was able to use Request.ServerVariables["REMOTE_ADDR"], though I
    understand that the data is not 100%.
    --
    Thanks
    Morris


    "Allen Chen [MSFT]" wrote:

    > Hi Morris,
    >
    > >I don't need the IP to send the email. I have a page with fields(name,
    > >phone, email, etc) that the user fills then clicks submit to download our
    > >demo. This sends me an email with the data from the fields. Normally the
    > >user does not enter the data (we do not force them to) so automatically
    > >getting their IP or Remote Host I can see if there were duplicate

    > requests,
    > >etc. My previous website using front page I was able to get this field

    > and
    > >hoping I can get similar data from my new asp.net website.

    >
    > From your description you want to restrict a user to download a file only
    > once, right? If so you have several options:
    >
    > 1. Check user's IP. The way to do so in ASP.NET is mentioned in my previous
    > post. Please note, due to the existing of proxy, the IP you get may not be
    > the real one of client. In addition, the way to bind to client's IP doesn't
    > mean one user can only download a file only once. User's IP may change in
    > many cases, such as accessing to the internet by dialing ISP to request for
    > IP.
    >
    >
    > 2. Check the MAC of network adapter of user's machine. This option is
    > better than checking IP because in most cases changing network adapter is
    > much more expensive. You can also check other hardware related information.
    > However, the difficulty is, we cannot get these information directly at
    > server side. To get these information we have to use client side techniques
    > such as ActiveX. At last, a user can still download a file twice if he uses
    > another computer to access your web page.
    >
    > 3. Let a user send you his identity. In your case you've already let him
    > send his phone number, etc. If you could force him to do so his identity
    > can be used to check duplicate request. This is the weakest way because a
    > user can cheat you by sending fake identity.
    >
    > In a word, there's no perfect way to restrict this. I think option 1 and 3
    > are the easiest way. It can help to avoid duplicate download request to
    > some extent. You can use the code in my previous code to check it. If you
    > have any further questions, please don't hesitate to ask.
    >
    >
    > Regards,
    > Allen Chen
    > Microsoft Online Support
    >
    >
    Morris Neuman, Jul 2, 2009
    #5
    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. Shige
    Replies:
    1
    Views:
    788
    Munsifali Rashid
    Jan 13, 2004
  2. brett

    Getting IP address of visitor?

    brett, Nov 7, 2006, in forum: ASP .Net
    Replies:
    9
    Views:
    813
    Mark Rae
    Nov 7, 2006
  3. bushi
    Replies:
    13
    Views:
    1,529
    Juan T. Llibre
    Apr 22, 2007
  4. PP

    Visitor IP Address

    PP, Jan 6, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    372
    bruce barker
    Jan 6, 2010
  5. bush
    Replies:
    3
    Views:
    274
Loading...

Share This Page