For practical purposes, I'm going to create a new ASP.NET MVC 3.0 application. My solution (Practice.sln) will have 4 layers:
- Pratice.Common (class library for my ViewModels)
- Pratice.Data (class library for EF)
- Pratice.Service (class library for business logic)
- Pratice.Web (asp.net mvc 3.0 project)
Suppose I have a view called "Login" that is strongly typed on the LoginModel defined at my Practice.Common level. LoginModel has 2 properties (username and password).
In my controller, when the user submits the form, I call the following method:
[HttpPost] public ActionResult Login(LoginModel model) { if(_service.ValidateUser(model)) return null; }
ValidateUser () is a method defined at my Pratice.Service level (inside my LoginService.cs file).
Im basically delegating the verification process to my service level ...
My question is this:
Given that Id like to use / take advantage of the membership provider and considering that most (if not all) of my logic happens at my service level, how can I transfer membership to my service level? (if it's even a good thing)
Also ... I planned to create my own membership provider, not built-in, since Im did not use all these generating TABLES and sprocs ...
Bonus question:
Is it considered best practice that all login and account management come directly from your controller and the rest of my business logic is stored inside my service level?
I am curious about the pros and cons of having βpartsβ of logic that occur directly inside the Controller and other βpartsβ that occur at the service level.
Of course, if someone has a link or article that explains this, I will be grateful!
Yours faithfully
source share