Posts

ASP.NET Core API: Returning Video File as stream and playing video stream in Angular Client Application

Image
In this article, we explore an implementation that involves serving a video file from an ASP.NET Core API as a stream and playing it within an Angular client application. Our goal is to demonstrate how to create a stream response from the API and seamlessly deliver it to the client.  During the development of server-side APIs, we often encounter scenarios where users need to download files in client applications. However, when dealing with large files, it’s more efficient to use streamed responses. For instance, if the file is a video, rather than downloading it to the client, we can directly play it in the video player within the client  application. In ASP.NET Core, the  FileStreamResult   object is utilized to write stream data to the response. This approach allows sending binary content using a  Stream  instance when returning a file as a  FileStream . Figure 1 illustrates the high-level implementation concept. Figure 1: ASP.NET Core API returning Stream to Angular Client Step 1: C

Accessing Azure SQL Connection String from Azure Key Vault in ASP.NET Core API

Image
In this article, we will see the use of Azure Key Vault access in ASP.NET Core application. Azure Key Vault is a cloud service for securely storing and accessing secrets. A secret is anything that we want to tightly control access to, such as Database Connection Strings, API Auth keys, passwords, certificates, cryptographic keys, etc. The Azure Key Vault helps to solve problems as follows: Secrets Management  - It can be used to Securely store and tightly control access to tokens, passwords, certificates, API keys, and other secrets like Database Connection String Key Management  - It can be used as a Key Management solution. Azure Key Vault makes it easy to create and control the encryption keys used to encrypt the data of the Application. Certificate Management  - It allows an easy provision, manage, and deploy public and private Transport Layer Security/Secure Sockets Layer (TLS/SSL) certificates for use with Azure.   More information of Azure Key Vault can be read from this link .

ASP.NET Core: Implementing CQRS and MediatR pattern in ASP.NET Core API

Image
In this article, we will see an implementation of the Command Query Responsibility Segregation (CQRS) pattern in ASP.NET Core API with MediatR.  In my earlier article , I have already explained the CQRS. In this article, we will focus on Mediator Pattern.  Mediator Pattern Mediator is a behavioral design pattern that reduces coupling between components of the program. This is achieved by using a special mediator object. This object decouples components by managing indirect communication across them. This pattern makes the application easy to extend, reuse, and modify individual components because they do not have any direct dependency across them. Figure 1, will provide a good idea of the Mediator pattern. Figure 1: The Mediator Pattern As shown in Figure 1, the Mediator object is responsible for listening to requests from each service object and passing them to the actual Handler object hence implementing the decoupling across the Services and Handlers. This helps to further maintain