From the course: Advanced ASP.NET Web API 2.2

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Configuring the dependency resolver

Configuring the dependency resolver

From the course: Advanced ASP.NET Web API 2.2

Start my 1-month free trial

Configuring the dependency resolver

- [Instructor] On the last part we created the Dependency Resolver using Unity. But, we cannot still use it. So, let us go now to Visual Studio and learn how to configure the Unity Resolver. Since we are creating a web API project, inside the solution explorer you are going to see an App_Start folder. And here we have the web API config.cs file which is the file that we use for configurations in a web API project. And here we see that we have only one method which is the file that we use for configurations in a web API project. So inside the Register method let us configure the Unity container. For that write in here "var container" is equal to "new UnityContainer". Now let us import the necessary name space which is the Unity. Then write in here "container.RegisterType". And in here, pass two parameters. The first parameter is going to be the interface that we want to inject in our Controller. And the second…

Contents