Reputation: 187
I'm new to C#, coming from a PHP background I'm accustomed to storing things like database/smtp config in an environment file excluded from source control, so that the application can run locally and in multiple environments. Is there an equivalent convention in C#/ASP.NET? Maybe an .ini file somewhere? Web.config is a possible candidate, but there is dependency information in there as well (like a composer.json), so maybe not.
Upvotes: 0
Views: 2877
Reputation: 410
web.config is correct. You can add custom key/value pairs using the appSettings tag:
<appSettings>
<add key="CustomKey" value="Custom Value" />
</appSettings>
and then accessing it through:
ConfigurationManager.AppSettings["key"]
ASP.NET Web Configuration Guidelines ConfigurationManager.AppSettings Property
Upvotes: 3