i'm looking for a way to get the client ip address inside controller. I've tried HttpContext.Current.Request.UserHostAddress
. This returns me ::1
. Right now the Webserver is running on localhost and the requst is from localhost, too. Will this method work after deploying ?
Asked
Active
Viewed 1,330 times
3
1 Answers
4
Yes it will work.Now it is returing localhost in IP 6 format.
There are only a few things you should remember about:
- If user is behind NAT or proxy it will show IP of NAT/proxy
- There is a discussion about more problems with wrong IP UserHostAddress gives wrong IPs

Community
- 1
- 1

Piotr Stapp
- 19,392
- 11
- 68
- 116