Last active
August 29, 2015 13:56
-
-
Save khellang/8914337 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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