Tags : appsettingsasp-netasp-net-mvcconfigurationmanagerweb.config
Application-wde configuration settings can be placed in the web.config file in the <appSettings> section. These can be read directly using the ConfigurationManager. It may make sense to decouple the ConfigurationManager from the uses of the settings in the app as this will allow you perform additional processing or read/update the settings from a database at a later time without changing the app too much.
<!--web.config snippet-->
<configuration>
<appSettings>
<add key="SiteName" value="Snippet Fire" />
</appSettings>
</configuration>
// In an ASP.NET MVC site this could be placed in the Models folder
// In an ASP.NET site it should be in the app_code folder.
public static class GlobalSettings
{
public static string SiteName { get {
return ConfigurationManager.AppSettings["SiteName"]; }
}
}
blog comments powered by Disqus