Latest Posts On Code Maze

How to Fix CORS Error With AnyOrigin and AllowCredentials

How to Fix CORS Error With AnyOrigin and AllowCredentials

In this article, we will learn how to fix the CORS protocol error with AnyOrigin and AllowCredentials in ASP.NET Core (The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time). We assume you know the basics of CORS and how...

Difference Between Build and Publish in Visual Studio

Difference Between Build and Publish in Visual Studio

Has anyone ever wondered about the difference between the build and publish functions in software development? As we know, both the build and publish are important steps in software development, especially when using Visual Studio for .NET applications.  Let’s check...

Single and Split Queries in Entity Framework Core

Single and Split Queries in Entity Framework Core

Entity Framework Core (EF Core) offers developers two powerful querying strategies: Single and Split Queries. In this article, we'll delve into the pros and cons of each, helping us make informed decisions for efficient data retrieval. The sample in our repository...

How To Check if a URL Is Valid in C#

How To Check if a URL Is Valid in C#

In the world of web development using .NET, it's crucial to make sure the web addresses (URLs) our application uses are correct and safe. In this article, we will understand the basics of how to check if a URL is valid in C#. We'll include some easy-to-understand code...

Using Serilog with Microsoft’s ILogger API

Using Serilog with Microsoft’s ILogger API

In this article, firstly we will explore how to integrate the Serilog logging package with Microsoft's ILogger API. We will then compare the output of both logging methods to highlight the difference. If you're new to Serilog, we recommend reading our article...

How to Get the Number of Weekdays Between Two Dates in C#

How to Get the Number of Weekdays Between Two Dates in C#

Manipulating date and time values is a common programming problem in many applications. Have you ever wondered how we can calculate the number of weekdays between two dates? Knowing how to do this can be crucial in scheduling, project management, or resource...

How to Get the Number of Lines in a Text File in C#

How to Get the Number of Lines in a Text File in C#

In C#, understanding how to count lines in a text file efficiently is a fundamental skill. This seemingly simple task is essential, especially in data manipulation, analysis, or validation scenarios. Whether we are dealing with log files, configuration files, or large...

Parallel.ForEachAsync() and Task.Run() With When.All in C#

Parallel.ForEachAsync() and Task.Run() With When.All in C#

Parallel programming is a common and broad concept in the .NET world. In this article, we compare two well-known methods we use to achieve it when running a repetitive asynchronous task. We take a look at how they behave under the hood and compare the pros and cons of...

Calculate the Difference in Months Between Two Dates in C#

Calculate the Difference in Months Between Two Dates in C#

Calculating the difference in months between two dates is a useful skill for C# developers. Having this knowledge helps us in tasks such as subscription management and tracking course durations. In this article, we learn how to use DateOnly, DateTime, and TimeSpan...

How to Call SignalR Hub from Controller in ASP.NET Core

How to Call SignalR Hub from Controller in ASP.NET Core

In this article, we will look at how to call a SignalR Hub from an ASP.NET Core controller. If you are unfamiliar with setting up SignalR in your server and/or client application, check out our article for more information. Did you know there are 8 different ways to set the URLs in ASP.NET...

How to Log a Class and Method Names Using Serilog

How to Log a Class and Method Names Using Serilog

Developers must implement an efficient logging system to maintain and troubleshoot applications effectively. One popular logging library that provides powerful logging capabilities is Serilog. In this article, we will talk about how to log class and method names using...