Appsettings.json environment: Setup files and use IWebHostEnvironment in .NET

preview_player
Показать описание

An ASP.NET Core C# application supports a development, staging and production environment out of the box.

Creating an appsettings environment file will take precedence over the main file. As a result, the variables in the environment file will override any variables in the main file if they are present.

And a separate appsettings file can be created per environment, allowing us to have multiple files that can change the variables and settings.

In-addition, the environment can be used into different parts of an ASP.NET Core web app. The IWebHostEnvironment can be injected, which determines what environment that application is running in. We'll show you how to do that, and how to use the "EnvironmentName" property to output the environment's name from the application.

💻 Download the code example for this demo 💻

📖 Learn .NET and C# with our online courses 📖

► Chapters
0:23 Learn .NET with our online courses
3:37 Read environment name in ASP.NET Core Web API
4:51 Preview of next part

#appsettings #environment #aspnetcore
Рекомендации по теме
Комментарии
Автор

Sent you a couple bucks. Copilot couldn't tell me this....Appreciate the video!

factionfx
Автор

Hi, your videos are really amazing! two thumbs up

juanalbertoboada
Автор

But when I deploy blazor server app on a Raspberry Pi, it doesn’t detect the product.appsettings file. Its keep using the appsettings.json file. What to do?

travelwithzohair
Автор

Hi thanks for wonderful explanation, that was helpfull

mchittaj