.NET code examples

Keyed services for ASP.NET Core dependency injection example

Keyed services for ASP.NET Core dependency injection example

Download the code example for injecting keyed services with dependency injection with an ASP.NET Core web app.
Azure DevOps pipeline example .NET project for CI/CD

Azure DevOps pipeline example .NET project for CI/CD

A .NET project for use in the CI/CD setup of a Azure DevOps pipeline. This demo can be used for a build and release pipeline.
FromQuery and other ASP.NET Core Web API attributes

FromQuery and other ASP.NET Core Web API attributes

An ASP.NET Core code sample that features examples of FromQuery, FromHeader, FromForm, FromRoute, FromServices and FromBody in a Web API.
ASP.NET Core custom logging provider to SQL Server database

ASP.NET Core custom logging provider to SQL Server database

Download & install this .NET code sample written in C# that uses a custom logging provider to log to a SQL Server database table
Create your own file logger

Create your own file logger

An ASP.NET Core for .NET 5 Web API which extends .NET Core's logging feature to log to text files in a HostedService.
.NET Worker Service setup to run background tasks as a Windows Service

.NET Worker Service setup to run background tasks as a Windows Service

A .NET 6 Worker Service example running background tasks as hosted services, and setup to run as a Windows Service
AppSettings.json example in .NET and C#

AppSettings.json example in .NET and C#

Download our appsettings.json example which focuses on how to read a value, using ConnectionString, environment and logging.
Data Annotation custom validator in ASP.NET Core

Data Annotation custom validator in ASP.NET Core

Download a Data Annotation custom validator written in C# that can be used in .NET with MVC and Web API for model validation.
A FromBody and FromQuery sample in ASP.NET Core Web API

A FromBody and FromQuery sample in ASP.NET Core Web API

An ASP.NET Core example of using the FromBody and FromQuery attribute. Handy if your request is null, or getting a 415 error.
Download a Blazor WebAssembly button onclick event example

Download a Blazor WebAssembly button onclick event example

Use a Blazor Wasm parameter to pass the onclick event to another Razor compoment and use it async. Download the code example.