Visual Studio confused when there are multiple system.web sections in your web.config

Posted by Jeff Widmer on ASP.net Weblogs See other posts from ASP.net Weblogs or by Jeff Widmer
Published on Wed, 26 May 2010 15:15:46 GMT Indexed on 2010/05/26 15:21 UTC
Read the original article Hit count: 592

Filed under:
|

I am trying to start debugging in Visual Studio for the website I am currently working on but Visual Studio is telling me that I have to enable debugging in the web.config to continue:

image

But I clearly have debugging enabled:

image

At first I chose the option to Modify the Web.config file to enable debugging but then I started receiving the following exception on my site:

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Config section 'system.web/compilation' already defined. Sections must only appear once per config file. See the help topic <location> for exceptions

 

So what is going on here?  I already have debug=”true”, Visual Studio tells me I do not, and then when I give Visual Studio permission to fix the problem, I get a configuration error.

Eventually I tracked it down to having two <system.web> sections.

I had defined customErrors higher in the web.config:

image

And then had a second system.web section with compilation debug=”true” further down in the web.config.  This is valid in the web.config and my site was not complaining but I guess Visual Studio does not know how to handle it and sees the first system.web, does not see the debug=”true” and thinks your site is not set up for debugging.

To fix this so that Visual Studio was not going to complain, I removed the duplicate system.web declaration and moved the customErrors statement down.

© ASP.net Weblogs or respective owner

Related posts about Visual Studio

Related posts about web.config