我认为我对SimpleMembershipProvider的理解差不多60%,其余的知道它是如何在内部工作的。
你可以很快地发现一些问题,当使用[InitializeSimpleMembership]过滤器只有在AccountController(默认模板)。我认为在任何地方使用Memberhsip API或WebMatrix.WebSecurity,你需要确保这个过滤器应该首先调用。
后来,如果你在我的_Layout.cshtml中使用User.IsInRole。您需要将过滤器应用于所有控制器,然后您开始在全局中注册它。
但是我只是意识到有LazyInitializer.EnsureInitialized使初始化只执行一次每个应用程序启动。
那么为什么SimpleMembershipInitializer(在过滤器中)不直接在Application_Start中?
有什么理由使用过滤器吗?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。