Global Error Handling in ASP.NET Core Web API using NLog

Introduction Implementing global error handling in an ASP.NET Core Web API using NLog involves setting up a custom middleware to catch and log exceptions that occur during the request pipeline. NLog is a popular logging framework for .NET that provides flexible and powerful logging capabilities. Here’s how you can implement …

Custom JWT Token In ASP.NET Core Web API

Introduction Creating a custom JWT token in ASP.NET Core Web API involves generating a JWT (JSON Web Token) with custom claims and using it for authentication and authorization. Here’s a step-by-step example of how you can create a custom JWT token in an ASP.NET Core Web API: Step 1: Create …

Create a Custom Middleware in ASP.NET Core

Introduction Custom middleware in ASP.NET Core allows you to add custom logic to the request and response pipeline. Middleware components are executed in the order they are added, providing a flexible way to handle cross-cutting concerns, such as logging, authentication, and more. Here’s how you can create and use custom …

Accessing/Retrieving Values From AppSettings.json In ASP.NET Core

Introduction In ASP.NET Core, you can store configuration settings, including key-value pairs, in the appsettings.json file. These settings can be accessed and retrieved from your application using the built-in configuration system. Here’s how you can access and retrieve values from the appsettings.json file in an ASP.NET Core application: Create or …

Implement And Register Dependency Injection In ASP.NET Core/.NET 6

Introduction Dependency Injection (DI) is a fundamental concept in ASP.NET Core and .NET 6 that enables you to manage the dependencies of your application components in a flexible and maintainable way. Here’s how you can implement and register dependency injection in an ASP.NET Core or .NET 6 application: What is …

Passing Data To View In ASP.Net Core MVC

Introduction In this article, we’ll discuss passing data to a view from a controller in ASP.NET CORE MVC. Please, read our previous article before proceeding to this article where we learn Views in ASP.NET Core MVC. So, there are three ways to do this we can either use 1. ViewData2. …

Controllers in ASP.NET Core MVC

Introduction In this article, we’ll discuss Controllers in the MVC .NET framework. If you choose the MVC framework then everything is a result of an action and actions are categorizing in controllers. Let’s see it in our application. Please, read our previous article before proceeding to this article where we …

Static Files Middleware in ASP.NET Core

Introduction In this article, we will discuss Static Files Middleware in ASP.NET Core and how it serves static files such as HTML, Images, JavaScript, and CSS files. by default, an ASP.NET Core application will not be able to serve static files to be able to serve static files. our application …

ASP.NET Core appsettings.json file

Introduction In this article, we’ll discuss the appsettings.json file in the ASP.NET Core application. the significance of appsettings.json file in previous versions of ASP.NET. we store application configuration settings like database connection strings for example in Webconfig.xml file. In an ASP.NET Core, configuration information can come from different configuration sources. …

ASP.NET Core InProcess Hosting

Introduction In this article, we’ll discuss InProcess Hosting in an ASP.NET Core and along the way, we’ll also discuss what is Kestrel server. Please, read our previous article before proceeding to this article where we learn ASP.NET Core Project Structure. So, within this program.cs file. we have this main method …