As Darin points out, ASP.NET MVC 4 is a Framework and is a container agnostic. Therefore, it provides a service locator in the form of an IDependencyResolver . This allows anyone to connect their own container of choice.
However, I would not call it an anti-pattern. This allows you to use the container of your choice, but it does not force you to the application developer to use the location of the service. If the structure forced the developer to use Service Location, I would call it an anti-template. But the developer who creates the ASP.NET MVC application is free to use DI through the installation of a constructor, property settings, or service location. This is their choice.
Check out all MVC MVC MVC implementation examples published by me or the ASP.NET MVC team. In almost all cases, they use constructor injection. They do not use the location of the service.
In fact, most of the ASP.NET MVC source code itself does not use the location of the service to extract dependencies. There are a few key places where MVC calls a service locator for legacy APIs, etc. But about that.
Haacked Mar 12 2018-12-12T00: 00Z
source share