2

How to get ip address in asp.net mvc 5?I have tried some solutions like but they are giving result as '::1' only so please suggest .Thanks in advance

ekad
  • 14,436
  • 26
  • 44
  • 46
  • see this http://stackoverflow.com/questions/2577496/how-can-i-get-the-clients-ip-address-in-asp-net-mvc – Zoman Aug 12 '15 at 09:29

2 Answers2

1

Sounds like you're doing it right to me. It will probably only show that IP when running locally

What is IP address ::1

Community
  • 1
  • 1
DrLazer
  • 2,805
  • 3
  • 41
  • 52
0

You can use the IHttpConnectionFeature

var ipAddress = httpContext.GetFeature<IHttpConnectionFeature>().RemoteIpAddress;

You can refer this article for complete explanation.

Varun
  • 597
  • 7
  • 26