Skip to content

Instantly share code, notes, and snippets.

@pjbgf
Created November 13, 2017 09:31
Show Gist options
  • Save pjbgf/a8971c40acac47baddba0c41e015abaf to your computer and use it in GitHub Desktop.
Save pjbgf/a8971c40acac47baddba0c41e015abaf to your computer and use it in GitHub Desktop.
Zombie Activator
[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