How to get appSettings value in web.config on framework net core 8

0
0

Dear All

How to get value from appSetings (“program.servername”) in web.config using net core 8.

<configuration>
<appSettings>
<add key=”Wisej.LicenseKey” value=””/>
<add key=”Wisej.DefaultTheme” value=”Bootstrap-4″/>
<add key=”program.servername” value=”localhost”/>
</appSettings>
</configuration>

in Framework 4.x,its return value=”localhost” using code

string value = System.Configuration.ConfigurationManager.AppSettings[“program.servername”];

 

but if using net core 8, return value=”null” using the same code. (program didn’t find the configuration key, i had try to copy file web.config to folder \bin\Debug\net8.0, the result is same).

 

Thanks

  • You must to post comments
0
0

Finally i got the answer.

  1. Download System.Configuration.ConfigurationManager  for net core 8 in Nuget
  2. Add file web configuration file, rename it app.config
  3. Add key dan value that you want
  4. <appSettings><add key=”program.servername” value=”localhost”/></appSettings></configuration>

base on this link

 

  • You must to post comments
0
0

This isn’t a Wisej specific issue- .NET Core doesn’t support web.config.
Wisej.NET reads its own settings using the ConfigurationManager class.
Configuration Manager documentation: https://learn.microsoft.com/en-us/dotnet/api/system.configuration.configurationmanager?view=net-8.0

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.