1
Vote

System.Web.HttpException: Could not find the specified membership provider.

description

Hi Mads,
 
I found you excellent XMLProvider library and source (VCS# 9237 - version 2.5) just in time to stop me re-inventing the same wheel!
 
I included it in my project; it works perfectly using the ASP.NET admin tool for the web-site (once I had removed read-only from the user and role files).
My main page comes up with no problem but when I try and use the LOGIN control on my login page (same directory as main page) I get the error at the end of this email.
I put a breakpoint in the "Initialize" method and stepped through the whole method with no problem (although I had to comment out the create inital user code as it caused endless looping and a therefore stack overflow).
As a result I cannot understand why the error is "could not find..." since it obviously did!
 
Any help or suggestions would be appreciated.
I have attached my web.config in case I have made an error there - although I don't think so.
Am I missing somthing obvious? Should I use v2.4?

 

Could not find the specified membership provider.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.Web.HttpException: Could not find the specified membership provider.
 
Source Error:
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 
Stack Trace:
 
 
[HttpException (0x80004005): Could not find the specified membership provider.]
System.Web.UI.WebControls.LoginUtil.GetProvider(String providerName) +1545897
System.Web.UI.WebControls.CreateUserWizard.get_QuestionAndAnswerRequired() +93
System.Web.UI.WebControls.CreateUserWizard.UpdateValidators() +580
System.Web.UI.WebControls.CreateUserWizard.CreateChildControls() +33
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +90
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +378

file attachments

comments

velio wrote Sep 1, 2009 at 7:12 AM

In your web.config you are using same sattings for the roles provider as for the membership.
I don't think roles provider has "minRequiredPasswordLength" for example.

So, I suggest you just fixing the providers section and replace:
<roleManager enabled="true" defaultProvider="XmlRoleProvider">
  <providers>
    <clear />
    <add applicationName="RTS" 
         minRequiredPasswordLength="1" 
         fileName="Roles.xml"
         minRequiredNonAlphanumericCharacters="0" 
         requiresQuestionAndAnswer="false" 
         requiresUniqueEmail="false" 
         passwordFormat="Clear" 
         name="XmlRoleProvider" 
         type="Artem.Web.Security.XmlRoleProvider" />
  </providers>
</roleManager>
with:
<roleManager enabled="true" defaultProvider="XmlRoleProvider">
  <providers>
    <clear />
    <add applicationName="RTS" 
         name="XmlRoleProvider" 
         type="Artem.Web.Security.XmlRoleProvider" />
  </providers>
</roleManager>
Regards

Forogar wrote Sep 1, 2009 at 7:50 PM

Thanks, I'll try that.

Forogar wrote Sep 1, 2009 at 9:38 PM

OK, I tried that (and also removed the profile provider information as I wasn't using it yet). No change. I get the same error.

velio wrote Sep 2, 2009 at 7:13 AM

Hmmmm,

Check out if Roles.xml and Users.xml files are existing in your App_Data folder.
Then check out if in Users.xml file the users password are in same format like the setting in you web.config.
In you web.config passwordFormat is Hashed. That means the passwords in Users.xml should be hashed, not in Clear format (as clear text).

If those above is not you case, you should get the sample website and check out how it is there.

Forogar wrote Sep 3, 2009 at 6:19 AM

OK, I found the problem. In my main page the membership provider worked and the breakpoint I put in the Initialize method was hit as I expected. in the login page the membership provider was still specified in the ASPX page itself from an old setup as "XmlMembershipProvider1". This was the name that didn't exist! Oops! When I removed that then everything worked fine. Sorry.

However, during testing I noticed a problem when validating users. I had to change the string.Equals(... in XmlUserStore.cs to a string.Compare(... in two methods, "GetUserByEmail" and "GetUserByName" as in the code below. This allowed for a non-case-sensitive comparison to be made. I hope this is a valid improvement for you.
    public virtual XmlUser GetUserByEmail(string email) {
        lock (SyncRoot) {
return (Users != null)
    ? Users.Find(delegate(XmlUser user) { return (0 == string.Compare(email, user.Email, true)); })   // replaced the string.Equals call
    : null;
        }
    }

    public virtual XmlUser GetUserByName(string name) {
        lock (SyncRoot) {
            return (Users != null)
                ? Users.Find(delegate(XmlUser user) { return (0 == string.Compare(name, user.UserName, true)); })   // replaced the string.Equals call
                : null;
        }
    }

Thanks for your time,
Robert (Forogar)

wrote Feb 14, 2013 at 12:09 AM