You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I set DOTNET_ENVIRONMENT to "Development" but app still thinks is "Production"
#r "sdk:Microsoft.NET.Sdk.Web"
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Configuration;
var builder = WebApplication.CreateBuilder();
var app = builder.Build();
app.Logger.LogInformation($"EnvironmentName: {app.Environment.EnvironmentName}"); // EnvironmentName: Production
// above should be Development
app.Logger.LogInformation($"IsDevelopment(): {app.Environment.IsDevelopment()}"); // IsDevelopment(): False
// above should be True
string env = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT", EnvironmentVariableTarget.Machine);
app.Logger.LogInformation($"env: {env}"); // env: Development
// above shows that env var is set
app.MapGet("/", () => "Hello world");
app.Run("http://localhost:5178");
The text was updated successfully, but these errors were encountered:
Nevermind. You have to open a new cmd window for env var edits to be applied in Configuration. But I guess that's not the case for GetEnvironmentVariable()
I set DOTNET_ENVIRONMENT to "Development" but app still thinks is "Production"
The text was updated successfully, but these errors were encountered: