Threads I searched
- ConfigurationManager.AppSettings count 0
- Reading settings from app.config or web.config in .NET
- ConfigurationManager.AppSettings is empty?
- WPF configurationmanager.appsettings collection is empty
My application is a .NET Core 3.1 app so I added the library System.Configuration.ConfigurationManager
via NuGet to my project. My root folder contains a Web.Config
with the following contents
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" />
<httpRuntime />
</system.web>
<appSettings>
<!-- Folder of LogParser job-configurations -->
<add key="JobFolder" value="App_Data/jobs"/>
<!-- Background task execution interval in seconds -->
<add key="Interval" value="5"/>
<!-- Message offset in seconds. Reads older messages to circumvent log4net timestamp bug -->
<add key="Offset" value="7200"/>
<!-- Caching duration for hash MemoryCache in seconds. Default is 604800 (7 days) -->
<add key="Caching" value="604800"/>
</appSettings>
</configuration>
However, when I access ConfigurationManager.AppSettings[key]
it's always empty. Also, Configurationmanager.AppSettings.AllKeys
is empty and the count is 0, as if it's not being parsed.
Any ideas?