Prevent Hangfire from starting in local Dev environment?

Using Visual Studio 2012 .NET webForms, I have my Startup.cs file in my root application. The “HttpContext.Current” is null when the site loads, meaning I can’t check the URL name to see if I’m on staging, dev, or production.

I’m trying to find an easy way to prevent hangfire from running/starting in my local development environment. Anyone have any experience doing this? Or any best practices on how to?

Why not setup configurations for each environment and then do a simple #if DEV_ENVIRONMENT

Assuming that you are working locally with debug build and deploy release configuration only, this will work perfectly:

#ifdef DEBUG
// Your debug-only code goes here
...
#endif

Thanks to both of you. Worked great, can’t believe I overlooked that :slight_smile: