日期:2014-05-20  浏览次数:20382 次

Web.config文件在.aspx.cs文件中的怎么读取?
web.config   文件
<configuration>
      <appSetting>
<add   key= "DSN "   value= "server=.;uid=sa;pwd=;database=pubs ">
<add   key= "SQL_products "   value= "select   *   from   Products ">
      </appSetting>
</configuration>

.aspx.cs   文件中:
string   con=ConfigurationSettings.
点时怎么点不出来的?还做什么工作吗?

------解决方案--------------------
在vs2005中是ConfigurationManager.Appsettins[ " "];
------解决方案--------------------
在VS2005里
读取Web.config建议使用专用的类
WebConfigurationManager.AppSettings[ "DSN "]

MSDN:
使用 WebConfigurationManager 是处理与 Web 应用程序有关的配置文件的首选方法;不推荐使用其他所有方法。对于客户端应用程序,建议使用 ConfigurationManager。
------解决方案--------------------
using System.Configuration;

string str=ConfigurationSettings.AppSettings[ " "]