Posts

Showing posts from January, 2022

ASP.NET Core 6: Downloading Files from the Server

Image
In this article, we will implement the file downloading feature using ASP.NET Core 6 application. In real-world applications, we can have various files like reports, spreadsheets, images, PDF documents stored on the server. (Note that all cloud-hosted applications prefer to store these files on the storage services, e.g. Blob, S3, etc.). But what if the client prefers to store files on the separate file server mapped to the web application host server? Then, in that case, we may need to download these files from the file server. In this article, we will implement exactly the same thing.   Step 1: Open Visual Studio 2022 and create a new ASP.NET Core MVC Application targetted to .NET 6. Name this application as Core6_FileDownload. In this project add a new folder and name it as ServerFiles. In this file add some images. (You can add Excel, PDF, Word, Files). Step 2: Since we need to read the ServerFiles folder using the ASP.NET Core application, we need to add the IFileProvider service

ASP.NET Core 6 SignalR: Creating Real-Time Charts in Blazor Web Assembly using C3.js

Image
In this article, we will implement the Real-Time Charts in Blazor WebAssembly Application using ASP.NET Core 6 SignalR. Creating Real-Time charts is one of the frequent requirements in Moden-Web Applications. This means that the chart must be generated without page postback. This must be implemented using SignalR. I have already published an article on Chart Creation in Blazor WebAssembly using C3.js. You can read this article from this link .     What is SignalR? ASP.NET Core SignalR is an Open-Source library that is used to add simplified real-time functionality to the Moden-Web Applications. The advantage of using Real-Time functionality is that it enables the content generated after server-side after execution to the client-side instantly. The ideal scenarios of using the SignalR are discussed in the following points Dashboard applications where the updates from the server are immediately pushed to the client. Gaming, Social App where high-frequency updates are pushed to the client

ASP.NET Core 6: Adding Custom Middleware and Logging the Error Message in Database

Image
 In this article, we will implement a custom Error Handler Middleware in ASP.NET Core 6. Middleware in ASP.NET Core Eco-System is a custom object that we integrate into the HTTP Request Response pipeline. This is a replacement for HttpModule and HttpHandler that was provided in ASP.NET and in MVC on .NET Framework. The HttpHandler and HttpModule were provided with IIS on Windows OS. Since the ASP.NET Core Eco-System is supported on Cross-Platform, the HttpHandler and HttpModule are replaced by the Middlewares. Implementation of the Custom Middleware The implementation of the custom middleware is done by adding  a new class in ASP.NET Core project. This class mus be constructor injected using the RequestDelegate delegate. This delegate is used to build the HTTP pipeline. Every HTTP request is handled by the RequestDelegate. This delegate invokes a method InvokeAsync()  that accepts the HttpContext as input parameter. The current HTTP request is represented using the HttpContext class. O