vb.net – ASP.NET WebForms: Adding StaticFileModule Rule for XML Causes “Duplicate Entry” Error and Breaks Index.aspx


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:

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?

Leave a Reply

Your email address will not be published. Required fields are marked *