I want to use Environment.IsDevelopment()
before builder.Build()
in Program.cs
. How should I do that?
var builder = WebApplication.CreateBuilder(args);
//Code: reach environment
var app = builder.Build();
I want to use Environment.IsDevelopment()
before builder.Build()
in Program.cs
. How should I do that?
var builder = WebApplication.CreateBuilder(args);
//Code: reach environment
var app = builder.Build();
2
Answers
It may not be what you are looking for, but I have used:
after
and before
This allows for more verbose exception pages in production (had a few issues where errors were thrown in production but not in development).
You can access which environment you are currently running as by using:
Prior to the application being built at this point:
After this code has run you would use: