Integrate Ninject

One of the most common patterns in programming is the Inversion of Control (IoC) design pattern. Sitefinity CMS provides a smooth integration of Ninject Dependency Injection (DI) framework and gives you the ability to use the IoC pattern when working with ASP.NET Web API.

The advantages of using the IoC design pattern are the following:

  • Reduces class coupling
  • Increases code reusability
  • Improves code maintainability
  • Improves application testability

The following article demonstrates how to use Dependency Injection for the constructor of a Web API controller. To achieve this, you create a custom Web API controller and define its constructor parameters via the Ninject API.

Ninject is a lightweight dependency injection framework for .NET applications. It helps you split your application into a collection of loosely-coupled, highly-cohesive pieces, and then glue them back together in a flexible manner. By using Ninject to support your software’s architecture, your code becomes easier to write, reuse, test, and modify.

PREREQUISITES:

You must install the Telerik.Sitefinity.Feather.Core package, version 11.0.6700.0 or above.

Install the required NuGet packages:

  1. Open your SitefinityWebApp and install NuGet package Ninject.Web.WebApi.WebHost
  2. Update the Ninject.Web.WebApi NuGet package to version 3.2.4.0.
    The Ninject and the Ninject.Web.Common packages must be version 3.2.2.0 and 3.2.3.0, respectively.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Tags

Was this article helpful?

Next article

Widget cache