views:

2386

answers:

2

I have implemented a custom membership provider using LINQ to SQL. When I added the Membership provider to my asp.net mvc website in the web config the logon page stopped working.

My Web.config setup:

<membership>
  <providers>
  <clear/>
    <add 
      name="MyMembershipProvider" 
      type="MyMembership.MyMembershipProvider"
      connectionStringName="ApplicationServices" 
      enablePasswordRetrieval="false" 
      enablePasswordReset="true" 
      requiresQuestionAndAnswer="false" 
      requiresUniqueEmail="false" 
      passwordFormat="Hashed" 
      maxInvalidPasswordAttempts="5" 
      minRequiredPasswordLength="6" 
      minRequiredNonalphanumericCharacters="0" 
      passwordAttemptWindow="10" 
      passwordStrengthRegularExpression="" 
      applicationName="/"/>
  </providers>
</membership>

The error I get is the following:

Parser Error Message: Default Membership Provider could not be found.

Source Error:

Line 53:      <forms loginUrl="~/Account/LogOn" timeout="2880"/>
Line 54:     </authentication>
Line 55:     <membership>
Line 56:      <providers>
Line 57:       <clear/>

I am stuck on where to proceed from here. I can't set a break point since the error seems to be called out of the main code.

I am using the standard membership code that comes with the default project of asp.net mvc. The membership provider is implemented in a separate assembly that is included in the web project.

Any help would be greatly appreciated.

Thanks!

+6  A: 

Try adding "Default=MyMembershipProvider" in the membership tag. If you don't specify the default, it will try to use the ASP standard.

Rob Conery
I added <membership defaultProvider="MyMembershipProvider"> and it worked! Thank You!
Lukasz
+1  A: 

2 things you can try. Number one: debugging is possible, just break on all exceptions and download the debug symbols including source code for the .NET framework.

Number two: since your type is defined in another assembly, the string in type probably needs to be an assembly qualified type string, i.e. it's like

type="MyMembership.MyMembershipProvider, MyAssemblyName"
chris166