Search code examples
c#web-configiis-8sitemapprovider

Strange 'MySqlSiteMapProvider' error although 'XmlSiteMapProvider' is being used


I've recently migrated a few web applications from a shared hosting environment to my dedicated server. The server is Windows Server 2012 R2 Standard and all my sites (all slight variations on the same C# web application) work fine however one of the sites is throwing this error when you try to browse to a page.

Server Error in 'ABC' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Host 'SERVERNAME' is not allowed to connect to this MariaDB server

Source Error: 


Line 283:    <siteMap>
Line 284:      <providers>
Line 285:        <add name="MySqlSiteMapProvider" type="MySql.Web.SiteMap.MySqlSiteMapProvider, MySql.Web, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
Line 286:      </providers>
Line 287:    </siteMap>

Source File: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config    Line: 285 

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2053.0

What's strange is that I'm using System.Web.XMLSiteMapProvider and not a MySQL provider (as the error seems to suggest), see below from web.config

<siteMap>
  <providers>
    <add name="Admin" type="System.Web.XmlSiteMapProvider" siteMapFile="~/MenuSystem/Admin.sitemap" />
    <add name="Branch" type="System.Web.XmlSiteMapProvider" siteMapFile="~/MenuSystem/Branch.sitemap" />
    <add name="Supplier" type="System.Web.XmlSiteMapProvider" siteMapFile="~/MenuSystem/web.sitemap" />
  </providers>
</siteMap>

There are two other versions of the same application (BETA & a clone) both work fine and their web.config files have the same sitemap providers. Why would this error be thrown and what does it relate to? Did I miss something when setting up IIS?


Solution

  • Note that the error is coming from the machine.config, not the web.config. All web.config files essentially inherit from the basic machine version. To override the providers, you can simply clear the list first. For example:

    <siteMap defaultProvider="Admin">
      <providers>
        <!-- Add this next line: -->
        <clear/>
        <add name="Admin" type="System.Web.XmlSiteMapProvider" siteMapFile="~/MenuSystem/Admin.sitemap" />
        <add name="Branch" type="System.Web.XmlSiteMapProvider" siteMapFile="~/MenuSystem/Branch.sitemap" />
        <add name="Supplier" type="System.Web.XmlSiteMapProvider" siteMapFile="~/MenuSystem/web.sitemap" />
      </providers>
    </siteMap>