I'm trying to make changes to web.config after running the application. It gives the following error.
Saving the file 'web.config' requires you to stop your debug session.
Would you like to stop debugging now?
I'm using Visual Studio 2012.
I thought it has to do something with Enable Edit and Continue
feature in visual studio. Still doesn't work.
Terminate a debug sessionClick the Stop button on the toolbar of the Debug tool window. Alternatively, press Ctrl+F2 and select the process to terminate (if there are two or more of them).
I just want to add something to the comment that janv8000 made about Edit and Continue, because I've just been having the same problem and managed to sort it.
To give some background, I had an existing web application, created in VS 2012. When I debug this project in VS 2013, I can edit the web.config file happily without restarting the debugger. I then created a new web application in VS 2013, and found that I got the error message in the original question when I tried to edit the web.config file.
The solution to this was to disable Edit and Continue for the individual project. The reason I highlight this is because there's a global debugger setting in Tools->Options->Debugger for Edit and Continue. This is not the option that causes this problem.
To solve it:
First off let me point out a quick fact. There are two different types of projects here.
WebSite
which is created by select New WebSite
from the Visual Studio menu.WebApplication
which is created by selecting New Project
and selecting ASP.Net Web Forms Appplication
Now the reason to point this is out is simple.
The first option allows you to change your web.config without performing an Application reset (only while Debugging). This is because the WebSite
project files are compiled as the pages \ files are requested. Therefore everytime you request a page the code is compiled. This is also why you can change code files while debugging with no problems.
The second type is a compiled application. Therefore all the code is compiled before runtime. In this scenario the AppPool (IIS, IISExpress) watches for changes to this file. If changes happen to this file the application MUST restart in order for changes to take affect. Now there is no way to stop this behavior as its part of the core AppPool
.
Here is an excerpt from MSDN:
Configuration Changes Cause a Restart of the Application Domain
Changes to configuration settings in Web.config files indirectly cause the application domain to restart. This behavior occurs by design. You can optionally use the configSource attribute to reference external configuration files that do not cause a restart when a change is made. For more information, see configSource in General Attributes Inherited by Section Elements.
Attempts to change a configuration file by someone who does not have permission to edit the file will not cause a restart of the application domain.
Full MSDN page. http://msdn.microsoft.com/en-us/library/ackhksh7.aspx
As it states here there is one way around it. By using the configSource
to reference external configuration files which you may change without a problem.
I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With