why web.config locks? please help, thanks!

  • Thread starter Thread starter david
  • Start date Start date
D

david

I found my web.config file always in lock mode, when I tried to modify it, I
ofter got "Can not create web.config" error. I had to reboot my machine, and
before I accessed any site I can modify it. I think microsoft creates the
..NET structure so that user can modify config file easier without restart
service. I am not sure why my web.config works like that? Could someone
explain this to me? And is there a easier way I can modify the config file
without restarting service or machine.

Thanks!
 
How are you trying to modify the web.config file? I am not to familiar with
the web.config file but I think it works in the same way as the app.config
file, meaning you can only read from it while your application is running.
So if this is a Web Service you may have to re-start the Web Service. So as
to why you have to re-start your computer..have you tried to stop the web
server/service first?

If you want to modify the file without re-starting the application you would
need to do something similar to this article:
http://www.devx.com/dotnet/Article/11616/0/page/1

It explains how you create a config file in memory while your application is
still running and then the changes are permanently pushed to the file when
the application closes. Note: this article talks about the app.config file
not the Web.Config but you might find it useful.

Ronny
 
First, thank you for your reply.

I think app.config is quite different from web.config, this is from the link
you gave to me.

Although both read the files at startup and cache the contents, if you
change a
Windows Forms configuration file, the changes don't take effect until the
next time
you start the application. In contrast, when you change an ASP.NET
applicationsconfiguration file, the framework recognizes the change
immediately.

I believe one of the important new feature of .NET is that you can change
the setting without restarting anything. It works fine on some of my
servers. it just not works on my home server.
 
As a side note about changing the app config file in a ASP.NET application.
yes the changes are read in after you make them but this is done by
restarting the application. Once this happens things like lost sessions can
happen.
 
Back
Top