0

I have a MVC.Net (classic) app. It has a project which has a Class Library. In this class library I have created a app.config file where I setup the appsettings. But at runtime I am always getting null.

Just to illustrate here is the example Solution

  • WebApp . Web.Config . MyClassLibrary . App.Config

So a solution has a project WebApp and this webApp has a class library. Class library has the App.config file and has some AppSettings.

At runtime, I am trying to get the value AppSetting under App.Config file but I am getting the null value. Using the blew code:

  public static string _rootfolder= ConfigurationManager.AppSettings["RootUploadDataFolder"].ToString();

If I add the AppSettings in Web.config file then I am able to get the values.

So what should I do to read the values from the App.Config file that is residing in the Class Library. Note that I have already reference the class library in the WebApp.

Salma
  • 129
  • 10
  • [Please check this link](https://stackoverflow.com/questions/1189364/reading-settings-from-app-config-or-web-config-in-net) it should answer your question. otherwise please be more descriptive or share a snippet what you have tried/done so far – end user Mar 29 '22 at 06:12

0 Answers0