bsp;可以用API直接访问配置信息,比如Request.Browser对象的属性直接获得browsercapabilities
或者调用Context.GetConfig,比如:
CustomConfigSettings Config=(CustomConfigSettings)Context.GetConfig("customconfig");
if(config.Enabled==true)
......
GetConfig可有第二个参数获得指定的URL的配置。
下面是一个保存应用自己的配置数据的例:
<configuration>
<configsections>
<add name="databases" type="System.Web.Configuration.DictionarySectionHandler" />
</configsections>
<databases>
<add key="pubs" value="server=localhost;uid=sa;pws="/>
<add key="nothwind" value="server=localhost;uid=sa"/>
</databases>
</configuration>
使用:
String dsn = (String)((Hashtable)Context.GetConfig("databases"))["pubs"];
或者调用Context.GetConfig,比如:
CustomConfigSettings Config=(CustomConfigSettings)Context.GetConfig("customconfig");
if(config.Enabled==true)
......
GetConfig可有第二个参数获得指定的URL的配置。
下面是一个保存应用自己的配置数据的例:
<configuration>
<configsections>
<add name="databases" type="System.Web.Configuration.DictionarySectionHandler" />
</configsections>
<databases>
<add key="pubs" value="server=localhost;uid=sa;pws="/>
<add key="nothwind" value="server=localhost;uid=sa"/>
</databases>
</configuration>
使用:
String dsn = (String)((Hashtable)Context.GetConfig("databases"))["pubs"];
| 对此文章发表了评论 |
