Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way for storing non-public configuration data in a .NET 4.0 application

my application uses the standard app.config to store the public configuration data. However, there are still some other data which are not public, but they still must be accessible all the time, persistent, changeable from out of the application as well as manually in case of some problems.

For example imagine that the application stores some licensing information within a file which must not be public available. However, an administrator must be able to edit this file using notepad or similar (without any special editors), so cryptography is out of the game.

Would you use isolated storage? Do you have some other suggestions? Since the application is not using any database, please do not consider storing withing a DB as an option, too.

So the question is how to store application data so that it is not as easy to modify by hand as with app.config, but still easily editable for a power user.

like image 405
Tomas Walek Avatar asked Mar 08 '11 14:03

Tomas Walek


People also ask

What can be used to store configuration settings of an application?

In a Microsoft Azure hosted application, a possible choice for storing configuration information externally is to use Azure Storage.

What are the different types of configuration files that the .NET framework provide?

This article describes the syntax of configuration files and provides information about the three types of configuration files: machine, application, and security.

Which file is used to store and configure the database connection string in .NET MVC?

By default, Sitefinity CMS stores the connection string to the database in the DataConfig. config file, located in folder ~/App_Data/Sitefinity/Configuration/. You can move the connection string to the web.

What is the use of ConfigurationManager in C#?

The ConfigurationManager class enables you to access machine, application, and user configuration information. This class replaces the ConfigurationSettings class, which is deprecated. For web applications, use the WebConfigurationManager class.


1 Answers

What about an include file?

Like the file attribute in the appSettings Element or the SectionInformation.ConfigSource Property?

<configuration>
    <appSettings file="machine-specific.config">
        <add key="Application Name" value="MyApplication" />
    </appSettings>
</configuration>

The included file can be protected from public access with regular filesystem access rights.

I would definitely NOT use isolated storage for that. Encryption would be ideal but since that is not acceptable for you...

Using environmental variables would work too I guess... But I would probably not use it myself.

like image 196
Jaroslav Jandek Avatar answered Oct 17 '22 00:10

Jaroslav Jandek