Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
ASP .NET page that displays your IP address.
JavaScript Other
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
myIP
.gitignore
LICENSE.txt
myIP.sln
readme.md

readme.md

myIP

just goofing off with ASP .NET and HttpContext.Current.Request.ServerVariables

Note: If you run this on your local machine you will get 127.0.0.1 as a result.

Usage

Navigate to the page and your IP address will be displayed.

Code

private string GetExternalIp() {
    string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
    if (String.IsNullOrEmpty(ip)) {
        ip = Request.ServerVariables["REMOTE_ADDR"];
    }
    return ip;
}

Copyright

Copyright (c) 2011 Robert Greiner. See LICENSE for details.

Something went wrong with that request. Please try again.