Software Blog

Let's Talk Software

Simple Injector in ASP.NET MVC & WebAPI

TLDR: Simple Injector is good, use it.

As most developers do, we use IOC in our ASP.NET MVC sites, it cleans up the code and allows for better testing.  If you're not familiar with check out this article on Dependency Injection.

One of the longest running IOC libraries is Structure Map, which we originally choose because of it maturity and stability.  After running with this for 4 (ish) years (with complete success), I started to look into different possibilities for my Injector library.  Knowing that Structure Map has every feature you would ever want leads me to think there might be code that is affecting performance.  I only use IOC for a Service Layer & Repository Layer injection and its very simple at that, so I really don’t need all of the bells and whistles. I would rather have less features and better performance.

Dependency Injection in .NET has matured over the years and we now have options upon options.  After researching and reading many different perspectives and gauging community participation, Simple Injector was to be my next experiment.  The following is how I set it up in a new MVC project. (fyi this is all with Visual Studio 2013)

read more
RSS
<1>