Skip to main content

Posts

Azure AI Search with C#: Build Smart Search (2026)

Learn Azure AI Search with C# — index data, run vector and hybrid queries, and add RAG to your .NET app. Start building intelligent search today. If your application's search box still runs a LIKE '%term%' query against SQL Server, your users are quietly suffering. They type "cheap laptop for uni" and get zero results because your catalogue says "affordable notebook for students." Azure AI Search with C# fixes exactly this problem: it combines classic keyword search, vector embeddings, and semantic reranking into a single managed service that you can drive from .NET with a few dozen lines of code. In this tutorial you'll build a working search index from scratch, run keyword, vector, and hybrid queries, and finish with a Retrieval Augmented Generation (RAG) pattern that grounds an LLM in your own data. This guide targets .NET 9 and the Azure.Search.Documents v11 SDK. Every snippet is runnable. We'll explain why each design choice matter...

C# Pattern Matching: Complete Guide with Examples (2026)

Learn C# pattern matching with this complete guide covering switch expressions, property patterns & list patterns. Runnable examples & best practices — start now! C# pattern matching is one of the most powerful features added to the language in recent years, and it fundamentally changes how you write conditional logic. Instead of long, nested if-else chains and clunky type checks, C# pattern matching lets you test the shape, type, and values of data in a single, readable expression. In this complete guide, you'll learn everything from basic type patterns to advanced switch expressions, property patterns, and list patterns — with runnable C# code examples you can drop straight into your projects. Whether you're a beginner searching for how to use the switch statement, an intermediate developer looking for best practices, or a senior engineer exploring advanced pattern matching in C#, this tutorial covers it all. Let's dig in. What Is C# Pattern Matchin...

SQL Injection Prevention in C#: Complete Security Guide

Learn SQL injection prevention in C# with parameterized queries, EF Core, and stored procedures. Secure your .NET database code today with proven examples. SQL injection remains one of the most dangerous and most common vulnerabilities in web applications today. If your C# application builds SQL queries by concatenating user input, it is almost certainly exploitable. In this guide on SQL injection prevention in C# , you will learn exactly how these attacks work, why they succeed, and how to secure your database queries completely using parameterized queries, Entity Framework Core, and stored procedures. Whether you are a beginner writing your first data-access layer or a senior engineer hardening a production system, this tutorial gives you practical, runnable examples you can apply immediately. What Is SQL Injection and Why It Still Matters in 2026 SQL injection (SQLi) is an attack where a malicious user inserts SQL code into an input field, tricking your application into execu...

ASP.NET Core Global Error Handling: Complete Guide 2026

Learn ASP.NET Core global error handling with middleware, Problem Details, and logging. Master exception handling best practices with runnable C# examples today. ASP.NET Core global error handling is the single most important thing you can add to a production API, yet it is the piece most tutorials skip. When an unhandled exception bubbles up in a poorly configured app, your users see an ugly stack trace, your logs are noisy and inconsistent, and attackers learn far too much about your internals. In this guide you'll learn how to implement global error handling in ASP.NET Core the right way — using centralized exception handling middleware, the RFC 7807 Problem Details standard, and structured logging — with practical, runnable C# examples you can drop straight into your project. Whether you are a beginner searching "how to handle exceptions in ASP.NET Core", an intermediate developer looking for best practices, or a senior engineer wiring up advanced error hand...

TDD in C# with xUnit and Moq: A Practical Guide

Learn TDD in C# using xUnit and Moq. Write tests first, code second with step-by-step examples and best practices. Start building better software today. TDD in C#: Why Writing Tests First Changes Everything TDD in C# is a development practice where you write a failing test before writing the production code that makes it pass. It sounds backwards, but test driven development in C# produces cleaner designs, fewer bugs, and code you can refactor with confidence. In this guide, you will learn how to practice TDD using xUnit and Moq — the two most popular testing libraries in the .NET ecosystem. If you have ever spent hours debugging a regression that slipped through manual testing, TDD is the answer. Instead of treating tests as an afterthought, you make them the driving force behind your design decisions. By the end of this article, you will have a complete, working C# TDD example you can apply to your own projects. What Is Test Driven Development in C#? Test driven deve...

ASP.NET Core Health Checks on .NET 10: Setup and Gotchas

Last updated: October 1, 2026 · Tested with .NET 10 (SDK 10.0.201), AspNetCore.HealthChecks.* 9.0.0, EF Core 10.0.12, SQL Server LocalDB Short answer: call builder.Services.AddHealthChecks() , chain one check per dependency, and expose it with app.MapHealthChecks("/health") . The endpoint returns Healthy with HTTP 200, or Unhealthy with HTTP 503. For real deployments you want two endpoints (liveness without dependencies, readiness with them), a JSON body for humans, and timeouts on every check. I built all of that in one .NET 10 app and hit it with curl. Every response below is real output, and three results surprised me: a 2-second timeout that let a check run for 6 seconds and still report Healthy, Degraded returning 200, and exception messages showing up in the public JSON. The Minimum Setup Health checks are part of ASP.NET Core itself ( Microsoft.Extensions.Diagnostics.HealthChecks is in the shared framework), so the basic version needs no NuGet package: va...

Deploy ASP.NET Core to Azure App Service in 10 Minutes

Learn how to deploy ASP.NET Core to Azure App Service step by step. Follow this guide with CLI, Visual Studio & GitHub Actions examples. Start deploying now! Deploy ASP.NET Core to Azure App Service — A Complete Step-by-Step Guide If you have ever wondered how to deploy ASP.NET Core to Azure App Service without spending hours wrestling with configuration, you are in the right place. Azure App Service is Microsoft's fully managed platform for hosting web applications, REST APIs, and backend services. It handles infrastructure, patching, and scaling so you can focus on writing code. In this tutorial, you will learn three proven ways to deploy your ASP.NET Core application to Azure — using the Azure CLI, Visual Studio, and GitHub Actions for CI/CD. By the end, your app will be live on the internet with a real URL. What Is Azure App Service and Why Use It? Azure App Service is a Platform-as-a-Service (PaaS) offering that supports .NET, Node.js, Python, Java, and more...