.NET code examples

Create an email template in .NET

Create an email template in .NET

Download an ASP.NET Core code example that generates a HTML string using Razor Views that can used for an email template.
Using authentication in a Minimal API with Swagger

Using authentication in a Minimal API with Swagger

Download this Minimal API authentication example where API key security has been added through an authentication handler, and has been integrated with Swagger.
Validate .NET configuration on startup example

Validate .NET configuration on startup example

Download the code example to validate .NET configuration on startup using data annotations or FluentValidation, so your app fails fast and never ships with broken config.
Using transactions with Entity Framework Core

Using transactions with Entity Framework Core

See a code example of how transactions are used in Entity Framework Core and how they can be committed and rolled back
Using global query filters in Entity Framework Core

Using global query filters in Entity Framework Core

Download a .NET 10 sample project demonstrating Global Query Filters in Entity Framework Core, including soft delete and multitenancy, and run it in Visual Studio to see how they work in practice.
Basic Authentication in ASP.NET Core example

Basic Authentication in ASP.NET Core example

Download the code example to add Basic Authentication to an ASP.NET Core Web API with Minimal API and controllers examples.
C# 14: New features with code examples

C# 14: New features with code examples

Download the code example and see what's new in C# 14. From extension members to simple lambdas, learn how these features make your code cleaner and smarter.
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.
Minimal API code example for ASP.NET Core

Minimal API code example for ASP.NET Core

Download an Minimal API code example that allows you to test routes, parameters, results, filters, authentication and unit testing.
Exploring xUnit: Theory, Assert methods and Fixtures

Exploring xUnit: Theory, Assert methods and Fixtures

Download xUnit code examples so you can run unit tests with different Theory attributes, different assert methods and learn how to run tests with fixtures.