I was thinking of writing some code on Service Locator pattern until recently I notice loads of resources on the internet state that it is an anti-pattern. Service Locator seems appealing when I first saw it implemented with Unity DI container in Project Silk, a Patterns & Practices article by Microsoft. But the idea of having an global variable like object resolving dependencies rather than just using a DI container bothers me a lot. After reading these arguments, I decided to avoid using Service Locator pattern in MVC.
Here is a thorough introduction of Service Locator and DI by Martin Fowler :
Inversion of Control Containers and the Dependency Injection pattern
The purpose of IDependencyResolver in MVC 3 and 4 seems to be supporting legacy codes:
Why is MVC4 using the Service Locator Anti-Pattern
ASP.NET MVC 3 Service Location, Part 5: IDependencyResolver
Defense by Service Locator pattern side, but the definition of Service Locator here became the major point of the discussion:
To IServiceLocator or not