Sign in

Senior Application Developer. MBA. I write blogs about .NET, Angular, JavaScript/TypeScript, Docker, AWS, DDD, and many others.
Photo by Drew Perales on Unsplash

Numbers and Counting

  • A bunch of apples are arranged in a line, but a peach is mixed in the line. If we count from the beginning, the peach is the fifth in line. If we count from the end, then the peach is the seventh in line. How many apples are there in…


As announced in the .NET 6 Preview 4 blog, .NET 6 will release an improvement to ASP.NET Core: minimal APIs for hosting and routing in web applications. With these streamlined APIs, we can build microservices and small HTTP APIs with much less ceremony.

This is exciting and let’s take a…


In this post, I will first show you some basics of configuring Serilog for logging in .NET/ASP.NET applications. Then moving on to the topic of how to split or suppress logs. The source code can be found in my GitHub repository.

Serilog Configuration Basics

Serilog is a famous logging tool for .NET and…


C# has a feature, String Interpolation, to format strings in a flexible and readable way. The following example demonstrates the way how we usually output a string when we have data beforehand then pass data to the template string.

gist link

On the other hand, the String Interpolation doesn’t work…


We do different levels of tests against controllers. When unit testing controller logic, the test only executes the action method itself without going through the framework’s request/response pipeline. In other words, the filter attributes (e.g., the Authorize attribute ), model binding, and middlewares do not affect unit tests for controllers…


Most background jobs are running behind the scene and are transparent to end-users, and admins usually don’t need to worry about the nitty-gritty of how the system automates tasks or when the system executes them. In some cases, product owners may know that there are background jobs supporting the application…


We sometimes want to limit our application to only certain IP addresses or IP network ranges. For example, during beta testing, we prefer to only allow admins and preselected testers to access the new website. …


In this article, I will use a demo Web API application in ASP.NET Core to show you how to transmit files through an API endpoint. …


ASP.NET Core uses configuration providers to read configuration key-value pairs from a variety of sources. You can read more about configuration in ASP.NET Core in its official documentation, which has covered tons of use cases in detail.

Recently, when I set a JSON array in the appsettings.json files in an…


Caching is a common technique to reduce the number of trips for fetching data that seldom changes. Thus we can take advantage of caching to boost our application’s performance. ASP.NET Core provides several caching libraries, including in-memory caching, distributed caching, and many others. Among these caching techniques, IMemoryCache, the simplest…

Changhui Xu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store