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 this error:

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 app, 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?

1
  • Does it work if you give it a different name? Commented Nov 23 at 12:53

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.