2012-03-15 57 views
0

我正在申请。在那个应用程序中我添加了一个ashx处理程序在这里我想从配置文件中读取一些值,但我没有得到如何读取值。我使用的代码为如何读取ashx页面中的配置文件值?

public class MyHandler : IHttpHandler 
    { 
     public bool IsReusable 
     { 
      get { return false; } 
     } 


     public void ProcessRequest(HttpContext context) 
     { 
      //Here i want to read config values. 
     } 
    } 

回答

2

ConfigurationManager类可以在任何地方使用。如果您尚未完成,则必须添加对System.Configuration.dll的引用。

要读取配置值

public void ProcessRequest(HttpContext context) 
     { 
      var cfgValue = ConfigurationManager.AppSettings["cfgKey"]; 
     } 
+0

感谢.....!它的工作原理 – Dany 2012-03-15 07:56:17