Latest Posts On Code Maze

How to Get a JSON Array Using IConfiguration in ASP.NET Core

How to Get a JSON Array Using IConfiguration in ASP.NET Core

In this article, we will explore how to get a JSON array using IConfiguration. In modern web applications, JSON is a widely used data interchange format due to its lightweight nature and ease of use. When developing an ASP.NET Core application, it is common to store...

Readonly Modifier in C#

Readonly Modifier in C#

In this article, we are going to learn about the readonly modifier in C#. However, before we go into detail on this topic, it is important to understand the concepts of mutability and immutability in programming. [sc name="github"...

How to Use Mutex in C#

How to Use Mutex in C#

In this article, we are going to learn how to use the Mutex class in C#. Multithreading can significantly boost an application's performance, but it also brings challenges related to synchronizing and coordinating tasks across different threads (and even processes)....

How to Mark Methods as Deprecated in C#

How to Mark Methods as Deprecated in C#

In this article, we will explore how we can mark methods as deprecated and propose newer alternatives to developers in C# by providing useful information. [sc name="github"...

Implement API Key Authentication in ASP.NET Core

Implement API Key Authentication in ASP.NET Core

Many developers widely use API key authentication to secure API endpoints. This approach necessitates clients to provide a valid API key for accessing the endpoints. When implementing API key authentication in ASP.NET Core, it's crucial to understand how to pass the...

How to Mock IOptions in ASP.NET Core

How to Mock IOptions in ASP.NET Core

In this article, we'll unveil a straightforward approach to mock IOptions<T>, ensuring our tests remain both thorough and independent of real-world configurations. [sc name="github"...

Prevent SQL Injection With EF Core, Dapper, and ADO.NET

Prevent SQL Injection With EF Core, Dapper, and ADO.NET

SQL Injection is a severe security vulnerability that can harm applications that use databases. In this article, we'll learn about SQL Injection attacks, what they can do, and how to protect our applications from them. We'll focus on using popular ORM tools like EF...

How to Generate a Stream From a String?

How to Generate a Stream From a String?

Generating a stream from a string is a common operation we perform when building applications. In this article, we will discuss two ways we can achieve that in .NET.  [sc name="github"...

Differences Between Const and Readonly in C#

Differences Between Const and Readonly in C#

In this article, we will discuss the differences between const and readonly keywords in C#. const and readonly allow us to declare immutable values in C#. [sc name="github"...

How to Determine .NET Version Programatically

How to Determine .NET Version Programatically

.NET Framework allows us to create applications for various platforms and devices. With each new version, .NET introduces new features and fixes, while rarely including changes that could cause compatibility issues. Therefore, upgrading a .NET project to a newer...

Primary Constructors for Classes and Structs in C#

Primary Constructors for Classes and Structs in C#

In this article, we'll take a look at a new feature of C# 12 and .NET 8 for classes and structs called primary constructors that is still in preview at the time of writing the article. [sc name="github"...

Refactoring Couplers in C#

Refactoring Couplers in C#

In this article, we will learn about couplers, their impact, and how to find and fix them. Couplers establish dependencies between components, making our code challenging to understand, modify, and test. The knowledge about how to untangle our code can certainly help...

How to Configure Rolling File Logging With Serilog

How to Configure Rolling File Logging With Serilog

Logging holds a crucial role in software development, as it provides software engineers valuable insights into the behavior and health of their applications. Moreover, Serilog, a popular logging framework for .NET applications, offers a wide range of features. One...