Can i change Web.config property in Asp.net 2.0??

S

somequestion

i work on asp.net 2.0 so i have to change property of web.config file on the
web page

i mean when i make a board i want to change PageSize in the web.config file.

so i use ConfigurationManage.AppSettings["PageSize"] when i getting property
value.

but i also want to set this property.

ConfigurationManager.AppSettings["PageSize"] = "10"; <==== it's not work
because it doesn't have setting property

<appSettings file="GlobalSettings.config">
<add key="PageSize" value="15" />
......
give me some help ..please...
 
J

Juan T. Llibre

re:
but i also want to set this property.

You can't set AppSetting properties like that.
If what you're looking for is a way to modify web.config on the-fly, see :

http://msdn2.microsoft.com/en-us/library/system.configuration.appsettingssection

Remember, though, that if you do that your application will restart.
This is new in the .Net Framework 2.0.

See the complete system.configuration namespace at :

http://msdn2.microsoft.com/en-us/library/2a1tyt9s(en-US,VS.80).aspx





somequestion said:
i work on asp.net 2.0 so i have to change property of web.config file on the web page

i mean when i make a board i want to change PageSize in the web.config file.

so i use ConfigurationManage.AppSettings["PageSize"] when i getting property value.

but i also want to set this property.

ConfigurationManager.AppSettings["PageSize"] = "10"; <==== it's not work because it
doesn't have setting property

<appSettings file="GlobalSettings.config">
<add key="PageSize" value="15" />
......
give me some help ..please...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top