A Custom Membership Provider *Without* a Database?

前端 未结 1 543
有刺的猬
有刺的猬 2021-01-29 01:38

I\'ve been looking around various SO questions, blog posts, and so forth regarding the changes to membership providers in MVC 4. While I like many of the changes and the simpli

相关标签:
1条回答
  • 2021-01-29 02:11

    You should be able to create a custom SimpleRoleProvider and plug it into your application by modifying the web.config to something like this:

    <add name="SimpleRoleProvider" type="MyCustomRoleProvider.SimpleRoleProvider, MyCustomRoleProvider"/>
    

    Where MyCustomRoleProvider is the name of the assembly that contains your implementation of SimpleRoleProvider.

    Then just rip out the initialization for SimpleMembership. This article describes how to simplify the initialization process for SimpleMembership. Basically remove the InitializeSimpleMembership attribute from the AccountController and move the initialization to the Global.asax Application_Start method. But in your case you would want to add any initialization required for your custom SimpleRoleProvider, if there is any required.

    For the implementation your are describing you will most likely have to also create a custom SimpleMembershipProvider.

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