Lara
Lara

Reputation: 3021

Write and access frequent changing information

I have a requirement where I need to write few information which will be changed frequently after the application gets deployed on server. Is there any way I can keep those information on some files of my asp.net application which when required can be updated and accessed in the application.

I tried to add the information in Web.config as that can be updated after deployment.Here is the code

<QueryConstants>
<add name ="SColumnName" value="UserId,First Name,Last Name,Description" />
<add name ="IColumnName" value="Company Name,Account Active Status" />
</QueryConstants>

but I am not able to access by the values from the keys. How to achieve it ?

Upvotes: 0

Views: 22

Answers (1)

Damith
Damith

Reputation: 63065

use app settings section as below in your web.config

<appSettings>
    <add name ="SColumnName" value="UserId,First Name,Last Name,Description" />
    <add name ="IColumnName" value="Company Name,Account Active Status" />
</appSettings>

then you can read as below

var sColumnName= ConfigurationManager.AppSettings["SColumnName"];
var iColumnName= ConfigurationManager.AppSettings["IColumnName"];

also check How do you modify the web.config appSettings at runtime?

Upvotes: 1

Related Questions