Hi There, I have a big solution where I have more than 20 projects in the same solution. now I want to combine the appSettings for all the projects in order to remove their discrepancy. I added my settings to the same level as my solution and added a virtual
folder and then added those settings as Links in individual projects. Now when I publish it, I can see those settings in the output folder but while debugging it tries to physically get the file from the Project location and it fails to start. is their any
way to combine and manage my setting from a central location?
Hi There, I have a big solution where I have more than 20 projects in the same solution. now I want to combine the appSettings for all the projects in order to remove their discrepancy.
There are several options. I use server variables. Read the configuration fundamental docs to learn how configuration works in ASP.NET Core.
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
None
0 Points
1 Post
Share linked appsettings in ASP.NET core Webapi while debugging
Mar 22, 2021 10:54 AM|craysx6|LINK
Hi There, I have a big solution where I have more than 20 projects in the same solution. now I want to combine the appSettings for all the projects in order to remove their discrepancy. I added my settings to the same level as my solution and added a virtual folder and then added those settings as Links in individual projects. Now when I publish it, I can see those settings in the output folder but while debugging it tries to physically get the file from the Project location and it fails to start. is their any way to combine and manage my setting from a central location?
All-Star
53711 Points
24035 Posts
Re: Share linked appsettings in ASP.NET core Webapi while debugging
Mar 22, 2021 11:22 AM|mgebhard|LINK
There are several options. I use server variables. Read the configuration fundamental docs to learn how configuration works in ASP.NET Core.
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-5.0
Contributor
3550 Points
934 Posts
Re: Share linked appsettings in ASP.NET core Webapi while debugging
Mar 23, 2021 05:28 AM|l.laxmikant|LINK
you can keep all your config settings in the separate class library or maybe where you are having infrastructure-related functionality.
https://geeksarray.com/blog/read-appsettings-json-in-net-core-class-library-using-dependency-injection
Participant
1110 Points
371 Posts
Re: Share linked appsettings in ASP.NET core Webapi while debugging
Mar 23, 2021 07:47 AM|Jerry Cai|LINK
Hi, craysx6
Do you want to share the same appsettings.json file with different projects in the same solution?
You can add the following code to program.cs, to designate the json file to use:
The sharedSetting.json lies in the solution's root, can be called by all the projects in this solution.
More details you can refer to this link:
https://andrewlock.net/sharing-appsettings-json-configuration-files-between-projects-in-asp-net-core/
Result:
Best Regards,
Jerry Cai