Execute JavaScript Using Selenium WebDriver in C#
As developers, we always look for ways to make our work easier so we can focus on more exciting projects or learn new things. A big part of this is finding ways to quickly test our work, like new features or bug fixes, to ensure everything runs smoothly. This is where...
Introduction to Autofac FakeItEasy Package
In this article, we'll learn about the Autofac FakeItEasy Package, its features, benefits, and how to get started. We'll learn how to use the package to create unit tests for our applications. [sc name="github"...
Querying MongoDB With ObjectId in C#
In this article, we will look at how to retrieve MongoDB documents using ObjectId in C#. We will only cover how to query a MongoDB database using ObjectId in C#. Check out our article Getting Started with ASP.NET Core and MongoDB for more information on how to set up...
JsonNamingPolicy in C#: Built-in and Custom Naming Policies
JsonNamingPolicy is the System.Text.Json type that converts a C# property name into a JSON key. We assign one to JsonSerializerOptions.PropertyNamingPolicy, and the serializer calls it for every property it writes. Five policies are built in: CamelCase,...
dotnet build and dotnet run: Using the .NET CLI
The .NET CLI is the dotnet command, and seven of its subcommands do almost everything: new creates, build compiles, run compiles and starts, watch reruns on save, publish packages for a server, test runs tests, and add edits the project file. dotnet build is the one...
Publishing Blazor WebAssembly App to IIS
In this article, we will learn how to publish a Blazor WebAssembly application on IIS. Let's dive in. Setting up the App Blazor has three hosting...
How to Get an Access Token from HttpContext in ASP.NET Core
In this article, we will learn different ways to get an Access Token from HttpContext. Let's start. Understanding the HttpContext In...
Select a Dropdown Option Using Selenium WebDriver in C#
In this article, we will look at different ways to select a dropdown option using Selenium WebDriver in C#. We will use ASP.NET Core application and xUnit tests to showcase different approaches to our goal. [sc name="github"...
File Access Modifier in C#
In this article, we will learn about the File Access Modifier in C#. We will focus on what problems it solves and how to use it. ...
How to Decode a JWT Bearer Token in .NET
To decode a JWT in .NET, we pass the token string to JsonWebTokenHandler.ReadJsonWebToken() from the Microsoft.IdentityModel.JsonWebTokens package and read the header and claims from the JsonWebToken it returns. Decoding checks nothing, so we trust none of what we...
Tuple Aliases in C#
In this article, we will take an in-depth look at tuple aliases: what they are, how to use them, and the different rules that apply to them. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/csharp-intermediate-topics/TupleAliasInCSharp"...
Spectre.Console: Build Better-Looking C# Console Apps
Spectre.Console is a NuGet library that turns a plain, monochrome .NET console app into one with colored markup, tables, calendars, bar charts, progress bars, FIGlet banners and interactive prompts. We build each of these on one small list of students. After that, we...
Blazor WebAssembly Ahead of Time Compilation
In this article, we will explore the concept of ahead-of-time (AOT) compilation in Blazor WebAssembly projects. We'll explain how to enable AOT compilation, how it operates, and when it proves effective. Additionally, we'll look at how it optimizes applications with...
Hexagonal Architecture in C#: Ports and Adapters in .NET
Hexagonal architecture, also known as the ports and adapters pattern, keeps the application core independent of external components, such as storage, UI, and communication protocols. We will explain its structure, where it came from, and its advantages and...
How to Rename Files and Folders in C#
.NET has no File.Rename() method. To rename a file in C#, we move it to a new name in the same folder with File.Move() or FileInfo.MoveTo(), and to rename a folder we call Directory.Move(). We'll find the files first, rename one, then a whole batch, then a folder, and...
How to Switch Between .NET SDK Versions
In this article, we will learn how to switch between .NET SDK versions in our projects. By default, .NET uses the latest SDK installed on a given machine, even when developing with an earlier .NET runtime version. Actually, we can benefit from the latest SDK features...
How to Insert and Return Inserted Identity With Dapper
In this article, we will learn how to insert a record in an SQL database and return the inserted identity using Dapper. Let's begin!...
Local Functions in C#
In this article, we will learn about the local functions in C#. We'll explore the significance of local functions and how we can create them. Furthermore, we will discuss the best practices and compare them with lambda expressions. [sc name="github"...
How To Read the Request Body in ASP.NET Core Web API
The request body arrives as a forward-only stream, and whoever reads it first is usually the only one who gets it. That single fact decides everything about reading the request body in an ASP.NET Core Web API: where we can read it, whether model binding still works...
How to Determine the Operating System in .NET Core
In this article, we are going to find out how to determine the operating system of a computer on which our .NET Core application is running. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/dotnet-base-libraries/DetermineOperatingSystem"...
How to Use Request Timeouts Middleware in ASP.NET Core
In this article, we'll explore what the request timeouts middleware in ASP.NET Core does, how we can use it, as well as some advanced features we can leverage. [sc name="github"...









