As a matter of best practice in MVC, where should the logic go that deals with things such as password hashing/salting or data formatting before it gets sent to the database? I've read that the repository should only be used for logic that deals with data access. Is this something that belongs in a service layer? The controller? Does it even matter?
相关问题
- MVC-Routing,Why i can not ignore defaults,The matc
- How to dynamically load partial view Via jquery aj
- parameters in routing do not work MVC 3
- There is no ViewData item with the key 'taskTy
- TextBoxFor decimal
相关文章
- How to get a list of connected clients on SignalR
- How do you redirect to the calling page in ASP.NET
- Change color of bars depending on value in Highcha
- The program '[4432] iisexpress.exe' has ex
- ASP.Net MVC 4 Bundles
- Forward request from servlet to jsp
- How to get server path of physical path ?
- Cannot implicitly convert Web.Http.Results.JsonRes
I'd be inclined to put the hashing in the repository layer, if only for the practical reason that you know if there's more than one service class that needs to store passwords, you'll have some assurance they don't do the hashing differently. Basically, follow the DRY principle.
I think it depends on how you look at it. I'd be inclined to think of password hashing as something as necessary and therefore akin to, for example, escaping input before it goes to the database. In that case it would belong in the repository