-2

I have a value in a table in DB as 'Trial', i want to store this value in web.config and when Trial mode is true, this value should automatically be fetched from web.config. How to accomplish this task? (Store value from DB into web.config).

user43553
  • 65
  • 5
  • 14
  • 2
    You're reading a value from a database, then modifying Web.config, then checking the value to determine whether to fetch the value from Web.config? Huh? It is not a good idea to modify Web.config after it's been deployed into a live site. It will cause your application to recycle. Why not simply read the configuration from the database and act on it in code directly? – NathanAldenSr Mar 21 '14 at 04:44

1 Answers1

0

Create a key in web.config named Trial. When Trial is true then get the value from web.config. Some pseudo-code:

if(Trial == true)  // compare the value
{
   //get value from web.cofig
}

For getting value from web.config refer to this question.

Community
  • 1
  • 1
Narendra
  • 3,069
  • 7
  • 30
  • 51
  • i want to get the value from Db to web.config. How to do this, so that if later the value is changed to Demo in DB it should work fine. -@Narendra – user43553 Mar 21 '14 at 04:28
  • Check the comment given in your question by @NathanAldenSr. Ideally web.config is not changed in run-time depending upon the database value. – Narendra Mar 21 '14 at 04:49