How To

How to Use Cancellation Tokens in ASP.NET Core
By Tan Lee Published on Feb 03, 2025 413

ASP.NET Core 7, the latest version of Microsoft's open-source web application framework, brings many advanced features from previous .NET versions, one of which is cancellation tokens.

How to Use Simple Injector in ASP.NET Core
By Tan Lee Published on Feb 03, 2025 4.06K

Dependency Injection (DI) is a design pattern where an object receives the dependencies it requires rather than creating them directly.

How to Prevent CSRF Attacks in ASP.NET Core
By Tan Lee Published on Feb 03, 2025 367

Cross-site request forgery (CSRF) is a type of attack where a malicious user tricks an authenticated user into performing unwanted actions on a web application.

How to use Filters in ASP.NET Core
By Tan Lee Published on Feb 03, 2025 243

Filters in ASP.NET Core allow developers to execute code at specific stages in the request processing pipeline. This enables running code either before or after specific phases of the pipeline, such as executing actions, handling authorization, or generating results.

Preventing Redundant DI Code in ASP.NET Core
By Tan Lee Published on Feb 03, 2025 206

When working with controllers in ASP.NET Core or ASP.NET Core MVC applications, you may encounter repetitive code related to dependency injection (DI).

How to Read Request Headers in ASP.NET Core
By Tan Lee Published on Feb 03, 2025 505

ASP.NET Core MVC is a lightweight, open-source framework built on top of the ASP.NET Core 5 runtime. It provides support for handling request and response headers, which are collections of key-value pairs exchanged between the server and the client.

How to Use BitArray in .NET
By Tan Lee Published on Feb 03, 2025 275

The BitArray class in .NET 7 is a versatile and efficient data structure for storing and manipulating bits of data. Each element in a BitArray holds a single bit, represented as a boolean value (false for 0 and true for 1).

How to Implement Resource-Based Authorization in ASP.NET Core
By Tan Lee Published on Feb 03, 2025 301

In this article, we will explore how to implement resource-based authorization in ASP.NET Core to enforce fine-grained access control over resources in scenarios that attribute-based authorization cannot handle.

Serial Port Communication in C#
By Tan Lee Published on Jan 08, 2025 2.29K

The SerialPort class in C# enables communication with a serial port in .NET. This article demonstrates how to send and receive data through a serial port, displaying the received data in a TextBox using threading.

How to Optimize StringBuilder Performance in C#
By Tan Lee Published on Feb 01, 2025 316

Strings in .NET are immutable, meaning that modifying a string creates a new object in memory, which can lead to performance issues.

How to launch browser and visit web site in C#
By Tan Lee Published on Oct 29, 2024 1.86K

To launch a web browser and visit a website in C#, you can use the System.Diagnostics.Process class.

How to Parse a Comma-Separated String from App.config in C#
By Tan Lee Published on Dec 20, 2024 633

In this article, I'll walk you through how to parse comma-separated integer values from app.config and load them into a HashSet for efficient lookups.