The entry ‘MySqlMembershipProvider’ has already been added

Alasdair North - 

Last week one of the websites I work on in my day job suddenly started erroring on me. I couldn't log in at all, no matter what credentials I tried. Whenever I tried anything that needed to check a user's membership I got an error.

Parser Error Message: The entry 'MySqlMembershipProvider' has already been added.

It was complaining about the piece of XML below from the Web.config file. It's the part of the configuration file that tells ASP.Net what connection string and other options to use for user authentication. This has worked happily for years, but it was suddenly causing configuration errors.

<membership defaultProvider="MySqlMembershipProvider">
  <providers>
    <add name="MySqlMembershipProvider"
      type="System.Web.Security.SqlMembershipProvider ..."
      ... />
  </providers>
</membership>

Searching the web didn't dredge up any answers, not ones that helped me anyway. I spent hours looking.

In the end it turned out that installing the latest version of Microsoft's WebMatrix had added some entries to my machine.config file. One of these entries looked like this:

<membership>
  <providers>
    <add name="AspNetSqlMembershipProvider"
      type="System.Web.Security.SqlMembershipProvider ..."
      ... />
    <add name="MySQLMembershipProvider"
      type="MySql.Web.Security.MySQLMembershipProvider ..."
      ... />
  </providers>
</membership>

That's the culprit. WebMatrix had added a membership with the same name. I simply changed the name of my membership provider to something else and everything started working again.

← other fixes or blog
Father of three, CTO of viaLibri, and an active member of St. Barnabas Church.

Latest Posts

comments powered byDisqus