3

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 ?

tereško
  • 58,060
  • 25
  • 98
  • 150
MR.ABC
  • 4,712
  • 13
  • 44
  • 88

1 Answers1

4

Yes it will work.Now it is returing localhost in IP 6 format.

There are only a few things you should remember about:

  1. If user is behind NAT or proxy it will show IP of NAT/proxy
  2. There is a discussion about more problems with wrong IP UserHostAddress gives wrong IPs
Community
  • 1
  • 1
Piotr Stapp
  • 19,392
  • 11
  • 68
  • 116