'Environment Variable for debugging in Visual Studio 2022

I have a problem in Environment Variable in Visual studio 2022. When I use Development there is no problem and it takes development AppSettings,

Environment_Variable_Development

But when I remove Environment variable to use production (Default AppSettings) it brings me Error and It doesn't run.

Environment_Variable_Empty

What should I do to use default AppSetting in debug mode?

the error is 404 not found :

Not_Found_Error



Solution 1:[1]

if you are using swagger check the swagger middlware. it should be out of development environment, just modify this line of code in program.cs:

if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

to this:

if (app.Environment.IsDevelopment())
{
}
app.UseSwagger();
app.UseSwaggerUI();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jafar ashrafi