Created
November 13, 2017 09:31
-
-
Save pjbgf/a8971c40acac47baddba0c41e015abaf to your computer and use it in GitHub Desktop.
Zombie Activator
This file contains 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
[assembly: PreApplicationStartMethod(typeof(ZombieActivator), "Run")] | |
public static class ZombieActivator | |
{ | |
public static void Run() | |
{ | |
try | |
{ | |
if (IsThisLikelyToBeProductionEnvironment()) | |
System.Web.HttpApplication.RegisterModule(typeof(ZombieModule)); | |
} | |
catch | |
{ | |
} | |
} | |
private static bool IsThisLikelyToBeProductionEnvironment() | |
{ | |
var context = HttpContext.Current; | |
return (!(context.Request.IsLocal | |
|| Regex.IsMatch(context.Request.Url.Host, "(test|dev|stag|staging|beta|uat)+", | |
RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment