To check for whether or not the request is from the local machine, do this:
bool isLocal = HttpContext.Current.Request.IsLocal;
if(isLocal)
{
// Do things that should only be done when request is local here
}
Note: Read HttpRequest.IsLocal documentation for more information.