Akshaya Deshmane
Akshaya Deshmane

Reputation: 31

how to get Ip address in asp.net mvc 4 or mvc 5

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

Answers (2)

Varun
Varun

Reputation: 597

You can use the IHttpConnectionFeature

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

You can refer this article for complete explanation.

Upvotes: 0

DrLazer
DrLazer

Reputation: 3123

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

What is IP address ::1

Upvotes: 1

Related Questions