SimpleMembershipProvider not working

前端 未结 5 1188
悲哀的现实
悲哀的现实 2020-12-04 22:37

I started a new internet project with VS2012 and am trying to just restructure my project a bit and I can\'t seem to keep the SimpleMemberhsipProvider working. Basically, a

相关标签:
5条回答
  • 2020-12-04 23:25

    In case others are getting this error and the above solution doesn't work, like in my case. It said invalid child object when I tried to add in the assemblies markup. I had to specify the roleManager and membership tags as below. Once I did that the update-database worked.

    <roleManager enabled="true" defaultProvider="SimpleRoleProvider">
          <providers>
            <clear/>
            <add name="SimpleRoleProvider" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData"/>
          </providers>
        </roleManager>
        <membership defaultProvider="SimpleMembershipProvider">
          <providers>
            <clear/>
            <add name="SimpleMembershipProvider" 
                 type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData"/>
          </providers>
        </membership> 
    
    0 讨论(0)
  • 2020-12-04 23:26

    First way

    Check the sphair's answer out (in current thread).

    Second way

    Add following assemblies to the web.config:

    <system.web>
      <compilation debug="true" targetFramework="4.5">
        <assemblies>
          <add assembly="WebMatrix.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          <add assembly="WebMatrix.WebData, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </assemblies>
      </compilation>
    </system.web>
    

    Update

    The WebMatrix.WebData assembly contains a start up method to initialize Membership/Role providers and enable RoleManager (PreApplicationStartCode.Start). But ASP.NET couldn't find that to run in your case. By adding these two lines of code, we force ASP.NET to search these assemblies for PreApplicationStartMethodAttribute(s).

    0 讨论(0)
  • 2020-12-04 23:29

    I had the exact same error running at my hosting company (WinHost.com - they are excellent BTW).

    My solution was to add to the web.config:

    <appSettings>
        <add key="enableSimpleMembership" value="true" />
    </appSettings>
    
    0 讨论(0)
  • 2020-12-04 23:31

    add the key to the Web.Config as the page:

    http://devbla.wordpress.com/2013/07/03/corrigindo-o-erro-no-aspnet-the-role-manager-feature-has-not-been-enabled/

    []'s

    0 讨论(0)
  • 2020-12-04 23:32

    Instead of adding the assemblies to the web.config as Mehdi Golchin suggests, an alternative is to change the assembly references on WebMatrix.Data and WebMatrix.WebData to CopyLocal=True.

    0 讨论(0)
提交回复
热议问题