Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

ASP .NET page that displays your IP address.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 myIP
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 myIP.sln
Octocat-spinner-32 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.