.NET code examples

TimeProvider example for mocking time and timer in xUnit

TimeProvider example for mocking time and timer in xUnit

A .NET 8 xUnit project which uses the TimeProvider and FakeTimeProvider class to mock time and a timer in unit tests.
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.
Create a PDF using HTML & CSS in ASP.NET Core

Create a PDF using HTML & CSS in ASP.NET Core

Download the code example to allow you to create free PDF documents in ASP.NET Core. Capture a website layout and create an invoice.
ASP.NET Core hosted service in .NET 6

ASP.NET Core hosted service in .NET 6

Download a ASP.NET Core hosted example in .NET 6. It's added to the IServiceCollection and uses dependency injection.
ASP.NET Core Google Authentication example in MVC application

ASP.NET Core Google Authentication example in MVC application

A code tutorial for adding Google authentication into an ASP.NET Core 3.1 Web API, including details on how to install it.
Integrate SignalR inside a React app

Integrate SignalR inside a React app

An .NET 5 code example building a React app inside an ASP.NET Core application, with SignalR integration for sending messages.