Skip to main content

5 posts tagged with "ASP.NET8"

View All Tags

4 min read
Adnan Rafiq
Validate Options on Startup

Validate Options<T> on Startup in .NET 8

The .NET 8 Host Builder allows you to bind configuration with C# objects by using AddOptions<T> and binding to the configuration.

It provides you an opportunity to validate the configuration values when the host (WebApplication or Hosted Server) is starting by using ValidateOnStart.

But there are two interesting aspects of it, which I will explain in this post.

8 min read
Adnan Rafiq
Validate Options on Startup

Validate Options<T> on Startup

The .NET 8 Host Builder allows you to bind configuration with C# objects by using AddOptions<T> and binding to the configuration.

It provides you an opportunity to validate the configuration values when the host (WebApplication or Hosted Server) is starting by using ValidateOnStart.

But there are two interesting aspects of it, which I will explain in this post.

26 min read
Adnan Rafiq
Understand Middleware Intuitively

What will you learn?

It is a long blog post, but it builds the foundation and deep understanding of the middleware in the ASP.NET 8 or previous versions starting with ASP.NET 6.

It explores middleware, introduces you to HTTP middleware and ASP.NET middleware. It deep dives how the ASP.NET middleware works & how it is actually built. Then you will learn different ways to create middleware in .NET and their pros and cons. Finally, you will build your own middleware pipeline using the ASP.NET approach. Do not miss the copy & paste console sample to debug the .NET like middleware pipeline.

The Middleware

What comes to your mind when you hear the word middleware?

Middle of nowhere. 馃儚馃槅 But that's not the case here.

In the middle of two soft(wares), right? But in the context of the ASP.NET 8 why do you need it? What does it do? How does it work?

9 min read
Adnan Rafiq
ASP.NET 8 Configurations With no magic strings

ASP.NET 8 Configurations

Do you love magic strings to get the configuration values? No. Me neither. It was a serious question except you are in JS/TS land.

The amazing .NET supports strongly typed configurations. After all, it is a typed language.

Let me show you the complete usage of strongly typed configurations in ASP.NET 8.

15 min read
Adnan Rafiq
ASP.NET 8 Configurations Simple but YET Complex Story Image

ASP.NET 8 Configurations Think about a piece of software; it could be a web or mobile application or an API. What's its purpose? Well, it's here to solve a single or multiple problems for you by offering a suite of unique features.

Now, let's say some of you are fans of a dark theme, while others love the bright hues of a light theme. How can one software cater to both tastes?

Enter Configurations!

Configurations help us customize how the software behaves. Interesting fact: this customization isn't always about you, the end-user. Behind the scenes, developers also utilize configurations to fine-tune the software's behavior, such as determining which database to connect to, adjusting log level based on the environment, deciding on scaling parameters, and more. Intriguing, isn't it?

In the same sense as a developer, the ASP.NET 8 is a software (framework) that solves a problem for you. Let's start with Web Application Host Builder in ASP.NET 8.

The WebApplication Host Builder

What comes to your mind when you think about the word Host?

A Host takes care of you. Remember, the last time you visited your Aunt鈥檚 home, the food, the movies, and everything they made possible for you.

But we are talking about the .NET, a cross-platform framework. What possible relevance does it have with Aunt鈥檚 home visit?

Well, the .NET Host takes care of your application by providing out-of-the-box features such as:

  • Configuration
  • Logging
  • Dependency Injection

and many more.