0
        var webClient = new WebClient();

        var ipAddress = webClient.DownloadString("http://checkip.dyndns.org");
        ipAddress = (new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b")).Match(ipAddress).Value;

// gives my site IP address

jps
  • 20,041
  • 15
  • 75
  • 79

1 Answers1

0

Use this:

this.HttpContext.Connection.RemoteIpAddress

It tells you about requester's host address and port number. Access this object inside your controller. It's usaually available in the form of HttpContext.Request.Host

Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126