Latest Posts On Code Maze

Code Maze Weekly #200

Code Maze Weekly #200

Issue #200 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks Log Request Headers Middleware for ASP.NET Core [ardalis.com] A simple middleware that logs your request headers can go a long...

Different Ways to Run Background Tasks in ASP.NET Core

Different Ways to Run Background Tasks in ASP.NET Core

In this article, we'll explore different ways of running background tasks in ASP.NET Core applications without depending on external providers. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/aspnetcore-features/RunningBackgroundTasks"...

Monolith and Distributed Monolith Architectural Patterns in C#

Monolith and Distributed Monolith Architectural Patterns in C#

In this article, we are going to discuss the monolith and distributed monolith architectural patterns. We'll cover what the patterns are, how to implement them in C#, and why we should use them over some other alternatives such as microservices. Let's start with a...

How to Properly Create Message Templates for Logging in C#

How to Properly Create Message Templates for Logging in C#

In this article, we delve into the world of message templates for logging mechanisms. We'll journey through the history leading to the current state of logging, laying a solid foundation for understanding. This knowledge equips us to tackle one of the most common...

How to Read XML Documents in C#

How to Read XML Documents in C#

In this article, we'll talk about how to read XML Documents in C#. In the preceding article, we addressed the creation of custom XML documents. Also, we have already explored how to serialize and deserialize objects to and from XML in the articles titled Serializing...

How to Create XML Files in C#

How to Create XML Files in C#

In this article, we will explore how to create XML files in C#.  Let's dive in. Create Custom XML Files To create custom XML documents in .NET, we use an object...

Differences Between a Virtual and an Abstract Method in C#

Differences Between a Virtual and an Abstract Method in C#

In this article, we will learn about the differences between a virtual and an abstract method. Object-oriented programming thrives on inheritance – leveraging common functionalities across classes for efficient and organized code. However, regarding methods, C# offers...

Code Maze Weekly #199

Code Maze Weekly #199

Issue #199 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks How to get assembly code generated by the JIT for a C# method [www.meziantou.net] Did you know that starting with .NET 7 you can...

How to Get a Value of a Property By Using its Name in C#

How to Get a Value of a Property By Using its Name in C#

In programming, there are scenarios where dynamically retrieving the value of a property by its name becomes necessary. This guide delves into the intricacies of how to get the value of a property by using its name in C# using reflection. Assuming we have a...

How to Check if Items of a List Exist in Another List in C#

How to Check if Items of a List Exist in Another List in C#

One of the programming scenarios we can encounter once in a while is checking whether certain items in a list exist in another. This article is going to dive deep into all the techniques to compare lists. We are also going to compare how these techniques perform and...

Using MariaDB With ASP.NET Core Web API

Using MariaDB With ASP.NET Core Web API

In this article, we will discuss how to use a MariaDB database with an ASP.NET Core Web API. First, we will discuss what MariaDB is and how we include it in our application. Then, we will use the Entity Framework Core library to create a mapping between our Web API...

How to Calculate the Number of Days Between Two Dates in C#

How to Calculate the Number of Days Between Two Dates in C#

In this article, we will learn how to calculate the number of days between two dates, a task commonly encountered in various applications. We will achieve this by utilizing the DateTime struct, TimeSpan struct, and DateTimeOffset. [sc name="github"...

How to Truncate a String in .NET

How to Truncate a String in .NET

In the world of software development, we sometimes face requirements to shorten strings within our applications. A common use case is displaying text in user interfaces, such as labels, buttons, or columns in a table. To ensure that the text fits within a limited...

How To Remove HTML Tags From a String in C#

How To Remove HTML Tags From a String in C#

HTML, since its inception, has played a pivotal role in web development, serving as the foundational markup language for creating and structuring web pages. As developers, we engage with web-related data in our programming endeavors, it is a frequent scenario to...

Add Custom Claims to Access Token in Duende

Add Custom Claims to Access Token in Duende

In this article, we will show how to add custom claims to access tokens in the Duende Identity Server. Custom claims allow us to include application-specific information in ID and access tokens. This information encompasses details not covered by the standard claims...