How to get values from Web.Config file which is defined in AppSettings section as below?

<appSettings>
<add key="MaxSearchCount" value="100" />
</appSettings>

 Posted by vishalneeraj-24503 on 12/12/2013 | Category: ASP.NET Interview questions | Views: 1891 | Points: 40
Answer:

With the help off AppSettings method of ConfigurationManager class,we can get value from Web.Config file as:-

string max_search_count = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["MaxSearchCount"]);

max_search_count will have 100.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response