Dependency injection in ASP.NET Core - Course

How to use lifetimes in ASP.NET Core dependency injection?

How to use lifetimes in ASP.NET Core dependency injection?

We find out how the singleton, scoped and transient service lifetimes work in dependency injection and the differences between each one.
How to inject services in ASP.NET Core dependency injection

How to inject services in ASP.NET Core dependency injection

We'll show you how to use dependency injection to inject services into controllers, minimal APIs, Razor views and middleware in an ASP.NET Core application.
Use keyed services for multiple implementations of a service

Use keyed services for multiple implementations of a service

Learn how to add and inject keyed services into an ASP.NET Core application so you can add multiple implementations of the same services.
Dependency injection code example for ASP.NET Core

Dependency injection code example for ASP.NET Core

Download an ASP.NET Core dependency injection that allows you to register and test how the singleton, scoped and transient service lifetimes work.
How do you resolve scoped services in a background service?

How do you resolve scoped services in a background service?

Learn how to resolve scoped and transient services in an ASP.NET Core background service by creating a new scope and how it can also be used for multithreading.
How to write xUnit tests for dependency injection services

How to write xUnit tests for dependency injection services

Learn how to write xUnit tests for a class that injects services that uses ASP.NET Core dependency injection using mock and real instances.
Dependency injection code example for ASP.NET Core

Dependency injection code example for ASP.NET Core

Download an ASP.NET Core dependency injection that allows you to register and test how the singleton, scoped and transient service lifetimes work.

Free .NET code examples

Run an ASP.NET Core application in a Docker container

Run an ASP.NET Core application in a Docker container

Download a code example which includes a Dockerfile to build and publish an ASP.NET Core Web API into a Docker container and run the application.
Stripe .NET checkout example to add online payments

Stripe .NET checkout example to add online payments

Download an ASP.NET Core Stripe checkout example that uses the Stripe.net NuGet package to take online payments through a Web API endpoint.
Get started with Entity Framework Core

Get started with Entity Framework Core

Get started with EF Core includes creating a DbContext, adding a migration, CRUD operations, the Include method, raw SQL queries and stored procedures.
SignalR hub example sending chat messages in ASP.NET Core

SignalR hub example sending chat messages in ASP.NET Core

Download a .NET SignalR example which adds a hub that sends messages to clients when one is connected and when a method is invoked.

.NET 9 and C# 13 release

.NET 9 has been released and this is how you update

.NET 9 has been released and this is how you update

Find out how you can update your ASP.NET Core application to .NET 9 from updating Visual Studio, downloading the SDK and finding out about breaking changes.
Swagger dropped from .NET 9: What are the alternatives?

Swagger dropped from .NET 9: What are the alternatives?

Swagger has been dropped when using .NET 9 in the Web API template to create an ASP.NET Core app. We look at what other OpenAPI UI's are available.
Static asset file sizes can be reduced by over 80% in .NET 9

Static asset file sizes can be reduced by over 80% in .NET 9

Static asset delivery optimisation in .NET 9 uses Brotli and Gzip compression for static asset files which can reduce the file size by over 80%.
C# 13 - New features and how you can use them now!

C# 13 - New features and how you can use them now!

C# 13 has been launched as part of the .NET 9 release and we'll take a look at the new features and how you can start using them today.

Latest articles and tutorials

How to write xUnit tests for dependency injection services

How to write xUnit tests for dependency injection services

Learn how to write xUnit tests for a class that injects services that uses ASP.NET Core dependency injection using mock and real instances.
How do you resolve scoped services in a background service?

How do you resolve scoped services in a background service?

Learn how to resolve scoped and transient services in an ASP.NET Core background service by creating a new scope and how it can also be used for multithreading.
GetService or GetRequiredService in IServiceProvider?

GetService or GetRequiredService in IServiceProvider?

Find out whether you should use the GetService or GetRequiredService method in the IServiceProvider type to resolve a service from ASP.NET Core dependency injection.
Use keyed services for multiple implementations of a service

Use keyed services for multiple implementations of a service

Learn how to add and inject keyed services into an ASP.NET Core application so you can add multiple implementations of the same services.

Get started with EF Core - Free online course

Create a DbContext class in Entity Framework Core

Get started with EF Core as we set up an ASP.NET Core Web API project and create a DbContext and the SQL Server database it will connect to.

Entity Framework Core migrations: Add a migration

Learn how to add a migration to a DbContext using code first and update a SQL Server database with this EF Core tutorial.

Insert, update & delete a record in Entity Framework Core

This tutorial will add EF Core CRUD methods in ASP.NET Core Web API webpoints by inserting, updating and deleting from a DbContext.

Select rows using queries in Entity Framework Core

Learn how to create a EF Core query with LINQ that will select a single row and multiple rows of data with the option to add pagination.

Learn .NET with our online courses

ASP.NET Core in .NET 6: Dependency Injection

ASP.NET Core in .NET 6: Dependency Injection

Looking at dependency injection with C# examples for beginners. The course looks at what dependency injection is, the different service lifetimes, and some of the common errors.
Blazor WebAssembly: Building your first app

Blazor WebAssembly: Building your first app

Looking at how Blazor WebAssembly works and some of its benefits. Looking how it compares to Blazor Server and how Razor components work.
Blazor WebAssembly: Foundation skills

Blazor WebAssembly: Foundation skills

Focusing how to use configuration, authentication, API integration with HttpClient, logging, deployment in a Blazor WebAssembly app.
Advanced Blazor WebAssembly

Advanced Blazor WebAssembly

Advanced Blazor WebAssembly features, such as JavaScript interlop, SignalR, file uploads, state management and prerendering.