How to get a user’s client IP address in ASP.NET?

We have Request.UserHostAddress to get the IP address in ASP.NET, but this is usually the user’s ISP’s IP address, not exactly the user’s machine IP address who for example clicked a link. How can I get the real IP Address?

For example, in a Stack Overflow user profile it is: “Last account activity: 4 hours ago from 86.123.127.8”, but my machine IP address is a bit different. How does Stack Overflow get this address?

In some web systems there is an IP address check for some purposes. For example, with a certain IP address, for every 24 hours can the user just have only 5 clicks on download links? This IP address should be unique, not for an ISP that has a huge range of clients or Internet users.

Did I understand well?

21 Answers
21

Leave a Comment