How To
How to enable the built-in .NET Analyzers
By Tan Lee Published on Feb 04, 2025 543
.NET Analyzers are an essential tool for improving code quality by detecting potential issues, enforcing coding standards, and guiding best practices.
DataGridView index out of range exception
By Tan Lee Published on Feb 04, 2025 418
While working with WinForms in C#, you may encounter an issue when clicking on a column header in a DataGridView.
InvalidOperationException: Unable to resolve service for type
By Tan Lee Published on Feb 04, 2025 873
When the built-in dependency injection framework attempts to create an object, it needs to resolve all constructor parameters.
How to supply IOptions in ASP.NET Core
By Tan Lee Published on Feb 04, 2025 301
The options pattern in C# allows you to inject settings into a registered service through dependency injection. If your code uses this pattern, you will need to provide an IOptions<T> object.
Logging requests and responses in ASP.NET Core
By Tan Lee Published on Feb 04, 2025 457
In ASP.NET Core, logging HTTP requests and responses is a crucial aspect of monitoring and debugging applications.
How to manually validate a model in a controller in ASP.NET Core
By Tan Lee Published on Feb 04, 2025 518
Validating a model manually in ASP.NET Core can be approached in different ways, depending on your needs. You may want to validate a model object using its validation attributes, or you might need to apply custom validation logic.
How to add custom middleware in ASP.NET Core
By Tan Lee Published on Feb 04, 2025 461
In ASP.NET Core, the request pipeline is a series of middleware components that handle HTTP requests.
How to Turn Off Startup Logging in ASP.NET Core
By Tan Lee Published on Feb 04, 2025 523
When you launch an ASP.NET Core web application, you might notice several startup log messages in the console.
Dependency inject BackgroundService into controllers
By Tan Lee Published on Feb 04, 2025 259
To inject a BackgroundService into controllers in ASP.NET Core, you can't directly inject it through constructor injection like a normal service.
How to Configure JSON Serializer options in ASP.NET Core
By Tan Lee Published on Feb 04, 2025 717
ASP.NET Core uses System.Text.Json as the default JSON serializer. To customize the JSON serializer options globally, you can use the AddJsonOptions() method in the initialization code.
How to use Dictionary with tuples in C#
By Tan Lee Published on Dec 20, 2024 767
You can use dictionaries with tuples as either keys or values in C#.
How to Get all loaded assemblies in C#
By Tan Lee Published on Feb 04, 2025 530
In C#, you can get all loaded assemblies by using the AppDomain.CurrentDomain.GetAssemblies() method.