Reputation: 31
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
Upvotes: 2
Views: 1797
Reputation: 597
You can use the IHttpConnectionFeature
var ipAddress = httpContext.GetFeature<IHttpConnectionFeature>().RemoteIpAddress;
You can refer this article for complete explanation.
Upvotes: 0
Reputation: 3123
Sounds like you're doing it right to me. It will probably only show that IP when running locally
Upvotes: 1