日期:2014-05-17 浏览次数:20488 次
<?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="key1" value="5"/> </appSettings> </configuration>
Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/test.config"); KeyValueConfigurationCollection appSettings = config.AppSettings.Settings; //return appSettings["conn"].Value; 即使指定了test.config路径,读取web.config也正常 return appSettings["key1"].Value; //读取test.config报错