Showing posts from June, 2021

gRPC service in .NET 5: Consuming gRPC Service in Blazor WebAssembly Application

In the previous tutorial, we have seen how to perform database operations in gRPC service. In this tutorial, we will see go through the steps to consume the gRPC service in Blazor WebAssembly client application.  The Blazor WebAssembly, is the Blazor application hosting model where the .NET dependencies for Blazor WebAssembly application is loaded in the browser. This  application executed in the browser as interactive Web-UI as a pure browser application. The figure 1 shows how the gRPC Service application can be consumed in the Blazor WebAssembly application. Figure 1: The Blazor WebAssembly application      Note: Make sure that you create gRPC service by following the tutorial of create gRPC service with Entity Framework Core from this link . In this tutorial I have explained about all important packages those are mandatory in gRPC service so that it can be consumed by Browser client applications.   Step 1: Open the Visual Studio 2019 and create a new Blazor WebAssembly project. N

gRPC Services using .NET 5: Using Entity Framework Core with gRPC for Performing Database Operations

In this tutorial we will understand how to use the Entity Framework Core in gRPC service for performing database operations? What is gRPC? gRPC, is a modern high performance, open source Remote Procedure Call (RPC) framework. The gRPC can run on any environment. The most important features of gRPC are as follows It is language agnostic. There are tools available for many languages to generate strongly-typed server and client This supports server, client and bi-directional streaming calls Since it uses Protobuf binary serialization, it has reduced network usage This uses  Contract-first API  development   using Protocol Buffers by default The gRPC is ideal for developing lightweight microservices where efficiency is very critical. In real-time Point-to-Point services where streamed requests are needed to be handled then use of  gRPC can be idle.    The .proto files By default, gRPC uses Protocal Buffers. This is Google's mature open source mechanism for serializing the structured da

Blazor: JavaScript Interop Accessing JavaScript Functions in Blazor Components

Blazor, being the great technology for interactive Web UI, we can use it for modern front-end web applications. If you have an experience of other front-end technologies like React.js/Angular, you must have experience of writing modular code using JavaScript. We write the front-end application code in separate JavaScript files and using ES 6 modules (export / import) we access code of one JavaScript file other. While using Blazor for front-end application, it may be an application’s requirement that the code written in JavaScript file need to be accessed in Blazor component. Yes, it is possible in Blazor component using IJSRuntime interface. The IJSRutime Interface To access JavaScript functions from Blazor application, the IJSRuntime interface must be injected in the Blazor Component. This interface has following methods • InvokeAsync  o The method to access JavaScript function that returns value • InvokeAsync<Tvalue>  o The TValue, represents the type of value ret