Posts

Power BI: Accessing Data From Azure Hosted ASP.NET Core API to create Chart

Image
In the modern days of the application development the Power BI has been used a lot to turn related and unrelated data into the coherent, visually immersive and interactive insights. The data can be received from Excel Spreadsheets, SQL Server Database, cloud-based applications, etc. As shown in Figure 1, the Power BI can access data from various sources. Figure 1: The Get Data Features As shown in Figure 1, Power BI Uses various sources for accessing data so that it can be used by the business decision makers to get data for data transformation and use it in Visualize form to create charts Important Note: To Create database in Azure SQL and Publish API to cloud, you must have the Azure Subscription . Currently, most the data-oriented applications use REST APIs for data communications and Data fetching. Naturally, if we are using the Power BI for Data Visualization and Data Intelligence then what if the Data is to be received from the REST API then how we can access it in Power BI? In t

ASP.NET Core 8 API: Opening Excel File On The Server and Return its contents in JSON format

Image
ASP.NET Core is the best technology for building WEB Apps and API Services. The ASP.NET Core API offers features for building Data Communication services. We can connect various data providers to read their data and return it to the client applications. One such capability is to open an Excel file on the server and read its contents so that the client can respond to them in JSON format. Excel files play a very important role in storing data so that this data can be used for various business intelligence processes. We can develop ASP.NET Core API to directly open the Excel file on the server and return its contents to the client without downloading the file on the client. Figure 1 shows the application development process. Figure 1: Reading Excel file using ASP.NET Core API app The advantage of the above approach is that the file is available on the server and its data is sent to the client. To implement the solution we will be using the ExcelDataReader.DataSet package. This package is

ASP.NET Core: Using HTTPCLIENT with a Correct Way

Image
If you are building .NET Applications, then certainly your application needs to perform external API calls using HTTP Protocol.  Perhaps, if I say that the HTTP calls is a data fetching backbone of your applications then I won't be wrong. In such scenarios to perform HTTP calls we have the HttpClient class in .NET. The HttpClient class offers a great abstraction over managing HTTP Communications especially when the data communication is in the form of the JSON. The Figure 1 explains the scenario of the HTTP API calls. Figure 1: The HttpClient to Access HTTP APIs   But here are some possibilities where the HttpClient may be misused: If the new HttpClient instance is created every time, then that may result into port exhaustion.  Since the HttpClient implements IDisposable interface, we can use the HttpClient in the using statement for disposing its instance, but the problem is even after the HttpClient instance is disposed the underlying socker is not immediately release and this si

ASP.NET Core 8 API: How to implement REPR Pattern Endpoints in ASP.NET Core 8 API

Image
ASP.NET Core, is one of the best technologies for building APIs. In the modern world customer focused applications, the design and implementation of APIs is mandatory for fast data communications. The data can be in JSON format or even may be in the form of Binary Stream. In ASP.NET Core 6 onwards we have been introduced with Minimal APIs. The Minimal API eliminates the need for creating controllers. Yes, use of the controller approach is based on the typical MVC design approach. The MVC Controllers involves Views, ViewModels, etc. But in APIs, we use DTOs. Hence, the controller's approach does not really have any advantages because it has tendency to become bloated with numerous dependencies as we increase the number of endpoints, this also make the maintenance as a challenge. The Minimal APIs are the best. The Minimal API approach offers an endpoint that is directly mapped with the HTTP request type, and it provides a highly cohesive approach of dependency management along with r

ASP.NET Core 8: Creating Custom Authentication Handler for Authenticating Users for the Minimal APIs

Image
The ASP.NET Core is the superb technology for building modern web apps. One of the best features of ASP.ET Core is the ease of security implementation and its customization as per the application requirements. The Identity Object model of ASP.NET Core provides extensive customization to the developers so that they can implement the security logic as per the application's requirements where the Identity can be verified against the On-Premises and/or Cloud stores where the Users' credentials are kept.  In this article we will see an implementation of the custom Authentication Handler to handle the authorization of the request to the Minimal APIs. The Figure 1 provides an idea of the implementation Figure 1: The Authentication Handlers in ASP.NET Core Minimal APIs To implement custom authentication handler, we will be using the following classes: AuthenticationSchemeOptions:   This class is used to set the scheme for the authentication calls. The request to the API will be forward