O'Reilly logo

ASP.NET Web API 2 Recipes: A Problem Solution Approach by Filip Wojcieszyn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 9

image

Dependency Injection

This chapter covers dealing with dependency injection in Web API services. You will learn how to do the following:

  • Inject dependencies into Web API controllers, filters, message handlers, and formatters (Recipe 9-1 and 9-4)
  • Add support for the common DI containers (Recipe 9-2)
  • Deal with per-request dependency scope (Recipe 9-3)
  • Write a custom dependency resolver for ASP.NET Web API applications (Recipe 9-5)

9-1. Inject Dependencies into ASP.NET Web API Controllers

Problem

You would like to inject, through the constructor, dependencies into your ASP.NET Web API controllers.

Solution

ASP.NET Web API provides two primary ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required