Skip to content

Instantly share code, notes, and snippets.

@khellang
Last active August 29, 2015 13:56
Show Gist options
  • Save khellang/8914337 to your computer and use it in GitHub Desktop.
Save khellang/8914337 to your computer and use it in GitHub Desktop.
public static class RequestExtensions
{
public static bool IsLocal(this Request request)
{
var remoteAddress = request.UserHostAddress;
if (string.IsNullOrEmtpy(remoteAddress))
{
return false;
}
if (remoteAddress == "127.0.0.1" || remoteAddress == "::1")
{
return true;
}
// We don't have access to a local address, so we can't
// check if localAddress == remoteAddress.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment