Developing Blazor Hybrid Apps

Component-Based Development Component-based development allows developers to encapsulate UI components as independent Blazor components and reuse them across applications. This approach improves the maintainability and reusability of the code, similar to modern front-end frameworks such as React and Vue. Component = HTML + CSS + JS Blazor component = Razor + CSS + C# Introduction to MAUI MAUI is the cross-platform UI framework introduced in .NET 6, which allows developers to create native applications using C# and XAML. It is the evolution of Xamarin.Forms and supports Android, iOS, macOS, and Windows. ...

March 10, 2026

Gateway and Service Discovery

Building and Designing an API Gateway An API gateway is a server that acts as an intermediary between clients and backend services. It receives requests from clients and forwards them to the backend services. An API gateway can also perform other tasks, such as authentication, monitoring, load balancing, caching, request analysis, and logging. The BFF Pattern for Aggregating Multiple Services An API gateway can aggregate multiple services based on the BFF (Backend for Frontend) pattern. When a client requests data, the API gateway can call multiple services to fetch the data and then aggregate it into a single response returned to the client, reducing the number of round trips between the client and backend services and thereby improving performance. ...

March 10, 2026

Generating API Documentation with the OpenAPI Specification

Swagger is a language-agnostic specification for describing REST APIs. It lets computers and users understand what a REST API does without directly accessing the source code. The Swagger project was donated to the OpenAPI Initiative, and since then it has been known as the OpenAPI Specification. Swashbuckle is an open-source project for .NET Core. It is a collection of OpenAPI tools used to generate OpenAPI specification documents. It can generate API documentation automatically, including API descriptions, request and response formats, parameter descriptions, and more. ...

March 10, 2026

Getting the Time with TimeProvider

Getting the Time the Traditional Way We usually use DateTime.Now and DateTimeOffset.Now to get the current time, but code written this way is hard to test: the time depends on the system clock, which is difficult to control and reproduce — the only way to change it is to change the system time. var now1 = DateTime.Now; var nowUtc1 = DateTime.UtcNow; var now2 = DateTimeOffset.Now; var nowUtc2 = DateTimeOffset.UtcNow; The New TimeProvider Type To solve the problems above, .NET 8 introduced the TimeProvider type, which can be used to get the time and makes it easy to control the time in tests. ...

March 10, 2026

Globalization and Localization

Globalization means a web application can adapt to different cultures and regions without code changes. Localization means a web application can display different content based on the user’s culture and region. Globalization and localization are two different concepts, but they are often used together. There are many ways to implement multiple languages: resource files, databases, configuration files, and so on. This article focuses on the resource file approach, which is also what Microsoft officially recommends. Other options such as PO files and JSON files can also achieve multilingual support, but they are less convenient than resource files. ...

March 10, 2026

How to use Git version control gracefully

Introduction to Git Git is an open source distributed version control system for agile and efficient handling of any project, small or large. Clone repository Clone the remote repository locally, make modifications locally, and commit to the remote repository. Create repository Create a repository locally and push the local repository to the remote repository. Regarding the use of naming conventions for code repositories, use the KebabCaseLower nomenclature. Naming policy Original Converted PascalCase HelloShop HelloShop CamelCase HelloShop helloShop SnakeCaseLower HelloShop hello_shop SnakeCaseUpper HelloShop HELLO_SHOP KebabCaseLower HelloShop hello-shop KebabCaseUpper HelloShop HELLO-SHOP Local warehouse settings Git settings include global settings and repository settings, and multiple remote repositories can be set up. ...

March 10, 2026

Identity System and Identity API Endpoints

ASP.NET Core Identity architecture ASP.NET Core Identity is a mature identity system that provides user management, role management, claim management, password management, sign-in management, external login management, two-factor authentication, email confirmation, phone number confirmation, security token management, user lockout, user unlock, user sign-out, user deletion, user recovery, and more. Identity architecture explained Entity type Description User Represents a user. Role Represents a role. UserClaim Represents a claim that a user possesses. UserToken Represents an authentication token for a user. UserLogin Associates a user with a login. RoleClaim Represents a claim granted to all users within a role. UserRole A join entity that links users and roles. Storing Identity data with EF Core Defining entity types public class User : IdentityUser<int> { public DateTimeOffset CreationTime { get; set; } = DateTimeOffset.UtcNow; } public class Role : IdentityRole<int> { public DateTimeOffset CreationTime { get; set; } = DateTimeOffset.UtcNow; } Configuring entity types public class UserEntityTypeConfiguration : IEntityTypeConfiguration<User> { public void Configure(EntityTypeBuilder<User> builder) { builder.ToTable("Users"); builder.HasKey(x => x.Id); builder.Property(x => x.CreationTime); } } Reusing the Identity database context dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore public class IdentityServiceDbContext(DbContextOptions<IdentityServiceDbContext> options) : IdentityDbContext<User, Role, int>(options) { protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); } } Using the Identity API endpoints builder.Services.AddIdentityApiEndpoints<User>(options => { options.Password.RequireDigit = false; options.Password.RequireLowercase = false; options.Password.RequireUppercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequiredLength = 5; options.SignIn.RequireConfirmedAccount = false; }).AddEntityFrameworkStores<IdentityServiceDbContext>(); app.MapGroup("identity").MapIdentityApi<User>(); Working with Identity data Services such as UserManager, RoleManager, SignInManager, and PasswordValidator can all be used to work with Identity data. Unless there is a special case, it is not recommended to manipulate Identity data directly with a DbContext. ...

March 10, 2026

Implementing a Distributed Event Bus with Dapr

Abstracting the Distributed Bus Using design patterns, the way a distributed bus is used is abstracted, defining the basic capabilities of the bus. Event Bus-Based Components The distributed event bus is implemented in a componentized way, encapsulating the implementation details of the bus inside components. RabbitMQ-based implementation: https://github.com/dotnet/eShop/tree/main/src/EventBusRabbitMQ The Dapr Implementation of the Event Bus Dapr is an open-source distributed application runtime. Its publish and subscribe module enables microservices to communicate with each other using event-driven architecture messaging. Dapr provides an implementation of the event bus: publish events via Dapr, expose Dapr subscription endpoints, and route messages to different event handlers. ...

March 10, 2026

Implementing the Basket Service with gRPC

What Is the gRPC Communication Framework gRPC is a high-performance, open source, general-purpose RPC framework developed by Google. It is based on HTTP/2 and supports multiple languages (such as Go, Java, Python, C++, Node.js, Ruby, C#, Objective-C, PHP, and Dart). gRPC uses Protocol Buffers as its interface definition language (IDL). Protocol Buffers is a lightweight and efficient structured data serialization method, similar to XML or JSON, but smaller, faster, and simpler. ...

March 10, 2026

Implementing the Ordering Service with the CQRS Pattern

CQRS is short for Command Query Responsibility Segregation. It is a pattern that separates read operations from update operations: queries return results without changing system state and have no side effects, while commands change system state. Idempotency means that executing the same command multiple times produces the same result with no side effects. Why Use the CQRS Pattern In traditional architectures, the same data model is used to query and update the database. This is simple and works well for basic CRUD operations. ...

March 10, 2026