Dependency Injection In .Net Web Api
Create dependency Injection.

Dependency Injection In .Net Web Api


Article content
Create dependency Injection.
Article content
Configure dependency Injection. in Program.cs file


Day 3/75, In Dot Net How to configure and create Dependency injection in Controller and Service Layer?

first of all, create folders and make folder structure,

In Controller- we create dependency and making our API.

In Service Layer- here Is Business logic, validation.

In Common Layer (inside Model)- In model we define the request body and response body in Model.

IN Repository Layer- Main code of APIs in Repository Layer.

Now create Dependency in blow Screenshots, after that how to configure in program.cs this one screenshot in below.

Why We Use Dependency Injection ---The main advantage of DI (Dependency Injection) is our application is loosely coupled and has provided greater maintainability, testability, and also re-usability.

It is loosely coupled because dependency required by the class is injected from the outer world rather than created themselves directly win-in code.

I hope this first Article Help You

By Ravi Rajput

Need Your Support, Do Like and Share 😊🌸


To view or add a comment, sign in

More articles by Ravi Rajput

  • JavaScript(Basic top most 20)problems

    // 1. Program to find longest word in a given sentence function findLongestWord(sentence) { let words = sentence.

  • MSSQL SQL Database

    create database amazon use amazon create table customers( customer_id int primary key, first_name varchar(100)…

  • Console Class in C#

    I am Writing few basic programs in console class C# (C Sharp)

    2 Comments
  • SQL Database(MSSQL)

    SELECT - extracts data from a database UPDATE - updates data in a database DELETE - deletes data from a database INSERT…

    4 Comments
  • Reactjs Curd Operation

    Hi, I am Writing Here curd operation code in ReactJs, if you want you can implement. and and lets start process.

  • What is System Database in SQL Server Microsoft

    In SQL Server, the system databases are a set of databases that are created and maintained by SQL Server itself. These…

Insights from the community

Others also viewed

Explore topics