0

I'm running into a specific issue with my web.config when trying to serve XML files.

As soon as I add this rule:

<add name="XmlFile" path="*.xml" verb="GET,HEAD" 
     modules="StaticFileModule" resourceType="File" />

I only get an error when I navigate to Index.aspx:

Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'XmlFile'

If I delete the line or try this:

<remove name="XmlFile" />

then Index.aspx stops working and I get:

Server Error in '/Index.aspx' Application.
The resource cannot be found.
Requested URL: /Index.aspx

Everything else works. Only Index.aspx fails, and only when I touch this XML handler rule.

Environment:

  • ASP.NET WebForms written in VB.NET
  • .NET Framework 4.7.2

I need XML to be accessible but the rule shouldn't break the default page.

What is causing the duplicate-rule conflict, and why does removing it trigger a 404 specifically for Index.aspx?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.