Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of app.config in MVC 4

I have only few projects on my bag. In a previous desktop application when I wanted to store and use some application specific information I was using the app.config file.

Now I work on ASP.NET MVC 4 application and again I want to store some application specific information but this time I'm not sure. I have the web.config file which seems like a good place for this purpose but I'm not sure if it's the right place to store custom information there.

What is the right approach to do this? For example I want to save and extract path to directory on the file system where I'll save all my files. In ASP.NET MVC 4 what/where is the right place to do that?

like image 329
Leron_says_get_back_Monica Avatar asked Dec 07 '22 04:12

Leron_says_get_back_Monica


1 Answers

The web.config file is what web application use where a desktop application uses app.config, and it's a good place to put application specific information.

You can add keys to the <appSettings> tag, and use them in the application just as you would if you put them in that tag in the app.config file. Example:

string path = ConfigurationManager.AppSettings["DataPath"];
like image 104
Guffa Avatar answered Jan 04 '23 13:01

Guffa