ASP.NET Core AppSettings: How to read AppSettings.json in .NET (works with .NET 6)

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

Whether you're using .NET Core, or new versions of .NET, this video will show you how to use this configuration file in C#. In-addition, it'll show you how to read the connection string. This is useful if you're using SQL Server.

The AppSettings can be used in many web frameworks, such as a Web API, MVC and Blazor, and the samples used in this video will help you understand on how to implement it.

This video will also show how to group settings into multiple files, how to validate the configuration, and how to use it in a console application.

💻 Download the code example for this demo 💻

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

► Chapters
0:00 Introduction
0:48 Join our Discord Community
0:58 Create the Web Application
2:47 Setting up Custom Configuration
15:07 Validating Configuration
19:53 Create a Separate Configuration File
22:51 Importing Connection Strings Configuration
28:01 Using AppSettings in a Console Application
36:42 Good Support

#aspnetcore #appsettings #configuration
Комментарии
Автор

Thanks for this video, taught me everything I needed to know for what I was trying to achieve

TheOriginalAndBestTim
Автор

That is really good explanation even asp net core mvc and console too! Thank You! I did in .Net6 Asp Net Core MVC, it's just slightly different:
in the program.cs :

and in the controller I passed all with ViewBag like this:
ViewBag.Var1 = _options.Value.Name;
ViewBag.Var2 = _options.Value.Address;
ViewBag.Var3 = _options.Value.Age;

attilaguba
Автор

Hi David, that was a very nice video.

How would you seamlessly encrypt/decrypt values of your custom configuration section in appsettings.json file?

talhaanwer
Автор

Hi Davis pls! How would you read appsetting.json from validationattribute, I create one validation custom but return null, thk!

chacataplan
Автор

An object reference is required for the nonstatic field, method, or property 'member'

In the Program.cs (Startup in .net 6)

divanvanzyl
Автор

Excellent tutorial. Have been looking for the solution and got it here. Please share the discord link, I am not able to find it. Thanks.

gszpdmv
Автор

I like your hairstyle.... It seems like they were programmed.

liontalha
Автор

I did not actually watch the vidoe, I am only here to see the other stuff he has created.

reverendbluejeans