HttpContext is another HttpContext than you were used to since you are now using ASP.NET Core. That property can’t be found in the ASP.NET Core variant. An explanation of the differences is given by poke.
I would use Debugger.IsAttached, which not only checks if debugging is enabled, but also actively being debugged.