Latest Posts On Code Maze

How to Create a Custom Authorize Attribute in ASP.NET Core

How to Create a Custom Authorize Attribute in ASP.NET Core

Authorization is a security mechanism that determines a user's access level to a resource. We often need to implement custom authorization logic per the rules set by the organization or a project. In this article, we will learn how to implement a custom authorization...

Deep Copy of an Object in C#

Deep Copy of an Object in C#

In C#, when we create a new object that is a copy of an existing object, we can either create a shallow copy or a deep copy. Creating a deep copy of an object is often necessary when we need to modify the copy without affecting the original object, or when we need to...

Custom Event Arguments in Blazor WebAssembly

Custom Event Arguments in Blazor WebAssembly

When developing a website, we may want to respond to certain events with specific event data models that are different from the event data we receive from a standard event, such as a click event. Fortunately, Blazor WebAssembly provides a way to register our events...

Code Maze Weekly #166

Code Maze Weekly #166

Issue 166# of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks A first look at Blazor and .NET 8 [damienbod.com] An honest and insightful review of what Blazor brings us in .NET 8 by Damien...

The AddEndpointsApiExplorer Method in ASP.NET Core

The AddEndpointsApiExplorer Method in ASP.NET Core

In this article, we are going to learn about the AddEndpointsApiExplorer method in ASP.NET Core. We will learn why we need it and how we use it in our applications. For this article, we will use an ASP.NET Core Web API application with Swagger support. If you feel the...

Get Current User With Claims in ASP.NET Core

Get Current User With Claims in ASP.NET Core

In this article, we are going to see different ways to get the currently authenticated user using claims in ASP.NET Core. The code for this article is based on the respective code from the article on Authentication with ASP.NET Core Web API.  Async/Await and asynchronous programming are part of our lives for a...

Working With Zip Files in C#/.NET

Working With Zip Files in C#/.NET

In this article, let's look at some of the .NET classes we can use to read, create, and update zip files. Today compressed (zip) files are all around us....

Immutable Collections in C#

Immutable Collections in C#

Working with collections can be tricky, we all made that rookie mistake when we edited elements of a list while iterating on it. Now, we might not fall into this anymore, but there are cases where we want to ensure that our collections will remain unchanged. C# has a...

Using Trie Class for Efficient Text Pattern Searching in C#

Using Trie Class for Efficient Text Pattern Searching in C#

In this article, we will explore the Trie algorithm and how to use the Trie class in C# for efficient text pattern searching. The naive approach of searching through the text character by character can be inefficient, especially for longer patterns and larger texts....

Partial Classes In C# And How to Use Them

Partial Classes In C# And How to Use Them

In this article, we will review the concept of partial classes in C#. The main idea of partial classes in C# is that the compiler constructs a single class from separate source files. It knows to combine them into a single text file before performing the language...

Output Caching in ASP.NET Core

Output Caching in ASP.NET Core

In this article, we are going to discuss how to implement Output Caching in ASP.NET. Output Caching is a first-class feature in ASP.NET Core 7. Previously we needed to implement these features ourselves, so it's beneficial that Microsoft has now built this...

Code Maze Weekly #164

Code Maze Weekly #164

Issue #164 of the Code Maze weekly. Check out what's new this week and enjoy the read. .NET and C# Top Picks Implementing the Producer-Consumer Pattern with TPL Dataflow [markheath.net] Producer-Consumer is a specialized pattern you've...

How to Exclude Properties From JSON Serialization in C#

How to Exclude Properties From JSON Serialization in C#

In this article, we are going to learn how to exclude properties from JSON serialization using the two most prominent JSON libraries for .NET. The libraries are System.Text.Json, which has been natively available in the framework since .NET Core 3.0, and...

Alternative Way of Logging With OpenTelemetry Logging in .NET

Alternative Way of Logging With OpenTelemetry Logging in .NET

One of the most well-known debugging tools for developers is undoubtedly application logging, which allows us to record timestamped information about the current state of our application. In the OpenTelemetry project, logs are the third and final pillar of...

How to Find the Caller Method in C#

How to Find the Caller Method in C#

In this article, we will learn how to find the caller method in C#. We will also learn about scenarios in which this information could be useful and how to retrieve it. [sc name="github"...

How to Serialize a List to JSON in C#

How to Serialize a List to JSON in C#

JavaScript Object Notation (JSON) is widely used for storing, transmitting, and communicating data across different systems and applications. Its simple syntax and ability to represent complex data structures make it an ideal choice for web services and APIs. To...