In asp.net core Startup.cs Configure we are provided an IHostingEnvironment env parameter that exposes an env.IsDevelopment() call to determine if you are currently running in a visual studio f5 debug session or a cloud deployment scenario. In function app is there a story for determining this same thing so you can write code that only runs during f5 debug session, e.g. a populated (. . ., ClaimsPrincipal principal) dependency injected parameter where this is only normally assigned claims and roles when deployed into cloud EasyAuth enabled environment.
IHostingEnvironment.IsDevelopment()
actually checks whether the ASPNETCORE_ENVIRONMENT environment variable is set to "Development". If that's what you want to do then you can use Environment.GetEnvironmentVariable()
to check the value. However, to determine specifically if you're in an F5 debug session you should check Debugger.IsAttached
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With