473,378 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

ConfigurationManager and web.config and ASP.NET refresh curiosity

Hi all,

I was playing with the new ConfigurationManager class in the Feb CTP drop of
VS 2005 and I noticed that if you make changes to the configuration inside of
an ASP.NET page, those changes are immediately written to the web.config when
you say Configuration.Save() but if I then try to access them, they do not
appear to refresh within the request.

Not completely unexpected I suppose but I was wondering if anyone knew if
this is the way this is supposed to work or if the current request should
have picked up the changes?

Basically I added a new sqlCacheDependency using the configuration classes
and then called the constructor of SqlCacheDependency with the corresponding
information and it threw an exception because it couldn't find the setting I
just wrote out to the web.config. I got around it by doing a
response.redirect back to the page again and then executing the constructor
which worked but if the changes won't take until a new page loads then I'd
just like to know that is the case.

Thanks in advance for any help on this.

Jay
Nov 19 '05 #1
1 2420
> I was playing with the new ConfigurationManager class in the Feb CTP
drop of VS 2005 and I noticed that if you make changes to the
configuration inside of an ASP.NET page, those changes are immediately
written to the web.config when you say Configuration.Save() but if I
then try to access them, they do not appear to refresh within the
request.
The reason is that the request is executing inside of an AppDomain that has
cached the settings of the config file prior to the modification. You request
makes changes which invalidates the cached config data. Upon the next request
ASP.NET will launch a new AppDomain to load the new settings. So changes
made won't be visible until the next request into the application.
Not completely unexpected I suppose but I was wondering if anyone knew
if this is the way this is supposed to work or if the current request
should have picked up the changes?
So, from above, no this is not to be expected. If your request were to see
the changes immediaetly it would require creating the AppDomain and somehow
passing the current request (mid-stream) over to the new AppDomain that has
loaded the new settings. In short, it doesn't do this, so you won't see the
changed settings.
Basically I added a new sqlCacheDependency using the configuration
classes and then called the constructor of SqlCacheDependency with the
corresponding information and it threw an exception because it
couldn't find the setting I just wrote out to the web.config. I got
around it by doing a response.redirect back to the page again and then
executing the constructor which worked but if the changes won't take
until a new page loads then I'd just like to know that is the case.


Voila! :)

-Brock
DevelopMentor
http://staff.develop.com/ballen

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark Ingram | last post by:
Hi all, having a real struggle using the ConfigurationManager class, i want to be able to save user specific information to the configuration file, i try to use: Configuration config =...
4
by: Janiek Buysrogge | last post by:
Hello, Can somebody please tell me how I can read values from the following configuration file. It is generated by VS 2K5 Express when I add settings using the project properties front-end: ...
3
by: natasha | last post by:
Hello everybody, you can use ConfigurationManager.AppSettings.Set method (ConfigurationManager is in System.Web.Configuration namespace) to store a modified value from web.config. To be...
3
by: Mark | last post by:
I am trying to read the appsettings section of a configuration file using the ConfigurationManager object (ASP.NET application) with the following three lines but for some reason the...
1
by: -pb- | last post by:
Hi, I am tring to read the custom configuration form a config file but I am not getting any way to read the data from the config file. Here is tha sample. config file <?xml version="1.0"...
0
by: Jeremy Noring | last post by:
Hi, I have an application that loads various settings from the app.exe.config file. This has worked very well on w2k, XP, and Vista. However, recently I've been troubleshooting an issue on...
2
by: remya1000 | last post by:
i'm using VB.NET 2003. Last time while i did a program in Vb.Net 2005, i use "Configuration". and i could read and write to that XML configuration file like the example below. CODES:...
3
by: Jeff | last post by:
I have a solution with two projects. Project A is the startup project, while Project B serves as the project with the data logic. At run time, the first thing I need to do is write to Project...
0
by: Tom | last post by:
This seems odd ... While debugging my application in VS2008, I can successfully retrieve values from my configuration file doing the following: string bla = ConfigurationManager.AppSettings; ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.