0

I have modified my web.config file in my asp.net web application so that I am showing a custom error page:

<configuration>
    <system.web>
       ...snip
        <customErrors mode="On" defaultRedirect="WebForms/ErrorPage.aspx">
          <error statusCode="404" redirect="WebForms/ErrorPageNotFound.aspx" />
        </customErrors>        
    </system.web>  
</configuration>

When I run the site on IIS I get the following error:

Error code: 0x800700b7
Config section 'system.web/customErrors' already defined. 
Sections must only appear once per config file. 
See the help topic <location> for exceptions 

Clearly I have some config hierarchy at play here but I don't know which file I need to look at (I have 276 web.config files on my machine) - can someone point me in the right direction.

When I find the file can I just rem out the top level customErrors section or is this going to cause an issue for other web applications on the same machine that don't have customErrors defined?

1 Answer 1

1

That section should be modified on the root web.config

If you re receiving that error, maybe you have several web.config in sub-directories of your main application, you should start checking those to remove them

Clearly I have some config hierarchy at play here but I don't know which file I need to look at (I have 276 web.config files on my machine) - can someone point me in the right direction.

Why don't you simply use windows search to find documents containing the string customErrors

To enable Windows 7 advanced search:

http://answers.microsoft.com/en-us/windows/forum/windows_7-files/in-windows-7-i-want-to-search-for-all-files/aadfe1f1-4a33-406b-8e72-bb920efa4f30

Config files hierarchy

  1. Global machine. <windir>\Microsoft.NET\Framework\<ver>\Config\Machine.config
  2. Root Web config. <windir>\Microsoft.NET\Framework\<ver>\Config\Web.config
  3. Website. <wwwroot>\Web.config
  4. Web application. <wwwroot>|IIS Web Site path\<webapp>\Web.config
  5. Folder. <wwwroot>|IIS Web Site path\<webapp>\<dir>\Web.config
Sign up to request clarification or add additional context in comments.

2 Comments

And where do I find the root web.config there is nothing in c:\inetpub\wwwroot? I tried an advanced search but it didn't even find my applications web.config file (!)
I meant the root config file of your application. Any way, I updated my answer to show you the ASP.Net config hierarchy

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.