Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is Request.UserHostAddress reliable?
Message
From
19/08/2009 18:43:25
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01418265
Message ID:
01419113
Views:
48
>>>>>Hi,
>>>>>
>>>>>I need to log IP of the user who is using my ASP.NET application (access is anonymous). I found (by Googling) the call to Request.UserHostAddress as a way to get the IP. It works on my notebook where I see "127.0.0.1". How reliable this approach is when the user will be accessing the application on real Intranet or Internet?
>>>>>
>>>>>Thank you in advance for your help.
>>>>
>>>>It works fine. The only "issue" is that if the people are behind a NAT firewall you will see the address of the firewall, not the user. For example, my IP address is 192.168.1.100 and I hit a website. The website will see the address of our firewall which is 12.*.*.* (not the 192.*.*.* address). All users behind that firewall will appear to come from the same addres. I say "issue" because some people mistake this for a problem when it's exactly the correct behavior.
>>>
>>>I actually have to check my customers site to see if there are any error messages in the log file. And it will show me the IPs if there were read. Everybody who is using this application is on an Intranet (withing the company) so I am not sure how useful the IP will be in the error log. But I thought I will try to collect all possible information.
>>>Thank you for your message.
>>
>>If you are running your logging on the inside of the firewall and the users are inside the firewall (Intranet as you say) then the NAT shouldn't be invovled. I think Paul was indicating this for typical Internet access where all the users of a network are behind a firewall and accessing the web site outside the network.
>>Tim
>
>Thank you for clarifying it.

A lot of companies use DHCP to assign IP addresses on an intranet. With DHCP, a given workstation may get a different IP address every time it boots or restarts. So, if you record an IP address for troubleshooting purposes, a different computer may have that IP address the next day, which can be actively misleading.

If the intranet uses static IP addresses, this isn't an issue.

If they do use dynamically assigned IP addresses, you might be better off recording MAC addresses, which are unique per computer and don't change (if such a function is available).
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform