SimpleMembership - anyone made it n-tier friendly?

前端 未结 4 977
庸人自扰
庸人自扰 2020-12-24 03:38

\"SimpleMembership\", we\'re told, is the future of asp.net membership / role management. The MVC4 \"Internet Application\" template implements Account management using Simp

4条回答
  •  星月不相逢
    2020-12-24 03:54

    I think your question relates more to SoC than n-tier architecture (which is more about physical separation between layers as pointed out by @klatzib).

    I would argue that the logic within the membership providers should not be classed as business logic as they do not contain application or client specific code. In fact the idea of the provider model is that it fulfils a generic contract irrespective of the context in which it's used. A common mistake developers make is extending MembershipProvider and bolting in application specific business logic that should exist in a higher layer. If that's what you want to achieve with a alternative design, then that's the wrong approach. Providers are plugins for the .NET framework, and should be entirely abstracted from code. They certainly shouldn't contain your application domain, and you should very rarely need to extend them.

    Addressing your question another way, does the SimpleMembershipProvider prohibit SoC in application design or even n-tier architecture? No it doesn't. The MVC4 template is built for simplicity, but the ActionFilter used to initialize the provider is not part of the membership implementation, and you are free to initialize the the provider in any way you see fit (I prefer making this call from a DI container factory method). In fact SimpleMembershipProvider as no direct dependency on EF at all, so yes it is possible to remove references to EF DbContext in your web app.

提交回复
热议问题