Separating Concerns in ASP.NET MVC

If you're using ASP.NET MVC, chances are you're already a fan of SOLID Principles, Separation of Concerns, and perhaps Domain-Driven Design. If so, you may have run into the conundrum of how to remove references to your infrastructure projects from your application's entry point (for instance, your ASP.NET MVC project), since when following the Dependency Inversion Principle you want your application to depend on interfaces, not details.  Using an IoC container like StructureMap, you can easily configure your solution to achieve this, ensuring that at compile time there will be no way for developers to directly use types from your infrastructure project.  I've laid out the details with sample code in a full article on how to use types from a project without referencing it. Let me know if you find it useful, either in blog comments or on twitter where I'm @ardalis.

No Comments