NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Accesssing Configuration Settings

At runtime ASP+ uses Config.web configuration files to hierarchically compute a unique collection of configuration settings for each incoming URL request. Web developers – whether they are writing HttpModules classes, IHttpHandler instances, or ASP+ pages – can access these configuration settings using the GetConfig() methods exposed on the HttpContext object. The settings returned are not computed by ASP+, but rather by the IConfigSectionHandler class registered to handle a specific section of the configuration file.

The following example code demonstrates how you can access the <sessionstate> configuration data exposed for the current URL:

SessionStateConfig config = (SessionStateConfig)
                             Context.GetConfig("sessionstate");

if (config.CookieLess == true)  {
   // Cookieless sessions are activated…
}

if (config.InProc == true) {
   // InProc session state is being used….
}

The following example code demonstrates how you can access the <sessionstate> configuration data exposed for a specific URL:

SessionStateConfig config = (SessionStateConfig)
                   Context.GetConfig("sessionstate", "/MyDir/MyApp.aspx");

if (config.CookieLess == true)  {
   // Cookieless sessions are activated…
}

if (config.InProc == true) {
   // InProc session state is being used….
}

Important: Since the configuration settings might change at any time (for example, if someone updates a Config.web file), a developer should not attempt to cache any configuration settings themselves – and should instead rely solely on the configuration system to do this.