In ASP.Net project, you can place your configuration information in web.config. However, I prefer to place my config in an XML file and deploy it with the ASP.Net to web site. Here is one example to define my configuration class:
public class MyAppConfig {
private static _config = null;
// Configuration is a simple class with a list of properties
public static Configuration Configuration {
if (_config == null ) {
_config = new Configuration();
// parse XMl file and set properties
}
return _config;
}
}
In your case, you can use MyAppConfig to get web application level configuration properties:
public class MyBaseClass : System.Web.UI.Page
{
public override OnDo()
{
Configuration myConfig = MyAppConfig.Configuration;
// use properties ....
}
}
The advantage of placing configuration in your own XML file is that this component can be used in other apps such as console app with very little changes. However, you cannot write changes to the XML file in Web applications. Normally, I place writable information in databases to resolve the issue.