Visitor's IP Address

M

Morris Neuman

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.
 
A

Allen Chen [MSFT]

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:
(e-mail address removed).

==================================================
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.
 
M

Morris Neuman

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 said:
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:
(e-mail address removed).

==================================================
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.
 
A

Allen Chen [MSFT]

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
 
M

Morris Neuman

Thanks.

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top