Dela via


Accessing ASP.NET Configuration Settings

You can access public configuration settings from within an ASP.NET application by using the intrinsic static methods exposed by ASP.NET. For example, to read the value of the cookieless attribute of the <sessionState> section, you could use the following line of code.

Dim nocookies As Boolean = Session.IsCookieless
[C#]
bool nocookies = Session.IsCookieless;

Application-specific settings stored within the top-level <appSettings> section of Web.config files can be accessed using the ConfigurationSettings.AppSettings static string collection. For example:

Dim dsn As String = ConfigurationSettings.AppSettings("dsn")
[C#]
String dsn = ConfigurationSettings.AppSettings["dsn"];

See Also

ASP.NET Configuration | Configuring Applications