appsettings.json (Application Settings) is a settings file. When configured, it can be used by .NET as a configuration source for settings you need at runtime & is automatically used by IIS to load all relevant web server settings. You can have multiple appsettings.json files for various environments in the format of appsettings.Environment.json e.g. appsettings.Production.json. Also used commonly to store logging settings like level & verbosity.
Questions tagged [appsettings]
1058 questions
33
votes
1 answer
How to get Environment Variable in csproj file?
I want to get the environment variable in csproj, because there I have a condition which exclude appsettings from publish.
I want this because, my appsettings didn't depends to Solution Configuration, them depends only from environment…

Alex
- 1,013
- 1
- 13
- 27
29
votes
8 answers
How to get the key value from the AppSettings.Config file?
I'm trying to get my key value set in the appsettings.Config file but seems not working.
This is what i wrote for that. The code is called from the constructor of an MDI file and its returning only null value. Anybody know why?
var getValue =…

NewBie
- 1,824
- 8
- 35
- 66
28
votes
3 answers
AppSettings.json for Integration Test in ASP.NET Core
I am following this guide. I have a Startup in the API project that uses an appsettings.json configuration file.
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
…

Kevin Lee
- 1,104
- 3
- 13
- 33
27
votes
7 answers
Why do people consistently recommend using appConfig instead of using Settings files? (.NET)
Very often I see the answer to the question like: "How should I store settings in my .NET app?" is to edit the app.config file by manually adding entries to the app.config (or web.config) like so:
**

blak3r
- 16,066
- 16
- 78
- 98
26
votes
1 answer
How does reloadOnChange of Microsoft.Extensions.Configuration work for appsettings.json
In two projects (a .NET Core Web API and a .NET Core WindowsService) I am using appsettings.json for the configuration.
var configuration = new ConfigurationBuilder()
.SetBasePath(System.IO.Directory.GetCurrentDirectory())
…

monty
- 7,888
- 16
- 63
- 100
26
votes
1 answer
How do you put environmental variables in web.config?
I am currently Following these tutorials, and I am wanting to call the clear text string from Azure's Application Settings for Web Apps. I am under the impression that environmental variables are used for non-config files. However, I am wanting to…

Joseph Casey
- 1,283
- 1
- 14
- 34
24
votes
1 answer
Access appsettings.json values in controller classes
Having trouble figuring out how to read appsettings.json values outside of the startup.cs. What I would like to do is, for instance, is in the _Layout.cshtml, add the site name from the config:
For example:
ViewData["SiteName"] =…

Andy Evans
- 6,997
- 18
- 72
- 118
24
votes
8 answers
When to use .NET Settings vs config ?
Are there any recommendations on when to use Application settings (not per user settings) vs. .config file ?
Update
Looking to understand some of the finer and important differences because they're both effectively key/value stores.…

John K
- 28,441
- 31
- 139
- 229
23
votes
6 answers
Get the App.Config of another Exe
I have an exe with an App.Config file. Now I want to create a wrapper dll around the exe in order to consume some of the functionalities.
The question is how can I access the app.config property in the exe from the wrapper dll?
Maybe I should be a…

Graviton
- 81,782
- 146
- 424
- 602
23
votes
6 answers
Optional appsettings.local.json in (new format) visual studio project
My app uses appsettings.json for some settings. If appsettings.local.json is present, that should override appsettings.json for whatever settings it contains. So far, no problem.
But I use git for version control. Obviously, I don't want other users…

William Jockusch
- 26,513
- 49
- 182
- 323
23
votes
4 answers
ConfigurationManager.AppSettings["SettingName"] vs Properties.Settings.Default.SettingName when should I use each?
What should dictate when I should use the configurationManager.AppSettings or the strongly typed settings that visual studio generates? The strongly typed ones seem much more appropriate in most cases, but I suppose that it would be possible to add…

Sam Holder
- 32,535
- 13
- 101
- 181
23
votes
2 answers
Is it possible to have an ampersand sign in an appSettings key? error: web.config value is not defined
I have the following appSettings section
But the IDE is giving me two errors:
Error 25 Entity 'FormName' not defined.
Error 26 Expecting ';'.…

WhiskerBiscuit
- 4,795
- 8
- 62
- 100
22
votes
4 answers
Reading integers from AppSettings over and over
Some I do quite a lot of is read integers from AppSettings. What's the best way to do this?
Rather than do this every time:
int page_size;
if (int.TryParse( ConfigurationManager.AppSettings["PAGE_SIZE"], out page_size){
}
I'm thinking a method in…

Armstrongest
- 15,181
- 13
- 67
- 106
21
votes
7 answers
How to add configuration values in AppSettings.json in Azure functions. Is there any structure for it?
What is the standard structure to add keys to appsettings.json?
Also, how to read those values in our run.csx?
Normally in app.config, we had ConfigurationManager.GetSettings["SettingName"];
Is there any similar implementation in Azure Function?

Harshit Agarwal
- 323
- 1
- 2
- 6
21
votes
6 answers
Different application settings depending on configuration mode
Is anyone aware of a way that I can set application (or user) level settings in a .Net application that are conditional on the applications current development mode? IE: Debug/Release
To be more specific, I have a url reference to my webservices…

Maxim Gershkovich
- 45,951
- 44
- 147
- 243