Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving the file 'web.config' requires you to stop your debug session error

Tags:

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.

enter image description here

I thought it has to do something with Enable Edit and Continue feature in visual studio. Still doesn't work.

like image 842
Venkata Krishna Avatar asked Jan 10 '14 18:01

Venkata Krishna


People also ask

How do I stop a debugging session?

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).


2 Answers

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:

  1. Go to the project preferences for your web application (right click on it in the solution explorer and go to "Properties").
  2. Go to the "Web" tab.
  3. At the bottom of this tab is a section called "Debuggers".
  4. Uncheck "Enable Edit and Continue".
like image 81
Adam Connelly Avatar answered Oct 30 '22 08:10

Adam Connelly


First off let me point out a quick fact. There are two different types of projects here.

  1. A WebSite which is created by select New WebSite from the Visual Studio menu.
  2. A 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.

like image 27
Nico Avatar answered Oct 30 '22 09:10

Nico