I was working on a caching framework in ASP.NET Core and one thing I needed to know whether the application is running in debug mode.
In the regular .NET framework, this was available through the HttpContext, as per the following syntax:
In ASP.NET Core, this property is not available anymore and the HttpContext is now accessible from the Http namespace: Microsoft.AspNetCore.Http.HttpContext
Therefore, the usual way to check if the ASP.NET Core application is in debug mode is to check Debugger.IsAttached as per the following syntax:
//Your code here.
However, this property is true only when the application is attached to the debugging process. If you want to indicate that the application is running in development/debug mode and not on production server, you can add a key to the appsettings.json as per the following screenshot: