Skip to main content


Showing posts with the label .NET Core

Part-4 Asynchronous Data Communication Between Microservices Using RabbitMQ Message Broker With MassTransit[.NET6 Microservice Series]

In this article, we are going to establish asynchronous data communication between microservice using the RabbitMQ message broker along with MassTransit. Now let's take look at the 'Orders' GET endpoint response. Here we can understand we don't have 'Product' information. So we have to make a way to save the required 'Product' information into the 'SalesBusiness.API' microservice application from the 'Manufacture.API' microservice application. Steps we are going to accomplish this demo are: Configure RabbitMQ message broker with MassTransit for asynchronous data communication between the microservices. In the 'Manufacture' database we have a 'Products' table(like Master table), now we will create a new 'Products' table(like child table) in 'SalesDatabase', but here we will add only required columns. So that while fetching the 'Orders' endpoint it is to fetch required products information. So with he

Hot Chocolate GraphQL Pagination Using Cursor Technique[.NET 6]

In this article, we are going to understand the Cursor Pagination technique in Hot Chocolate GraphQL. GraphQL Cursor Paging: In GraphQL we have cursor-based pagination. The cursors are opaque, either offset or ID-based pagination can be implemented. In the cursor-base pagination based on request Graphql query response return 'Edges', 'PageInfo'(object). Edges consist of an array of objects with properties like 'node', 'cursor'. So 'node' property holds single record data into it. 'cursor' is a base64 string that can be either made by the row number or record primary key id value. So each 'edge' contains 'node'(contains single record data) along with 'cursor', so using the 'cursor' value we can query our server to return the records either before or after the 'cursor' value. PageInfo consist of  'hasNextPage', 'hasPreviousPage', 'startCursor', 'endCursor'. Sample Query

Part-4 Blazor Server Cookie Authentication

In this article, we implement the logic for the user logout from the Blazor server application. In this part of our article, we have to accomplish our targets like: SignOut Implementation. Generating Anti-Forgery Token. Create Sign-Out Razor Page: Since for logout we no need any UI page so we can implement our c# logic directly into the razor page so creating 'Logout.csthml' single file is enough. Areas/Identity/Pages/Accoun/Logout.cshtml: @page "/identiy/account/logout" @using Microsoft.AspNetCore.Authentication @using Microsoft.AspNetCore.Authentication.Cookies @inject IHttpContextAccessor _accessor @functions { public async Task<IActionResult> OnPostAsync() { await _accessor.HttpContext .SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); return Redirect("~/"); } } Here to sign out the user from the application w will use the 'Httpcontext.SignOutAsyn()' method by sending the authentica

Part-2 Blazor Server Cookie Authentication

In this article, we are going to implement User Registration logic in the Blazor Server application. In this part of the article, we have to accomplish our targets like: User Registration Form. Password Hashing User Registration Logic. Click here for part-1 Create Asp.Net Core Areas Folder: We are going to create Razor Pages for our User Registration, so let store them in the 'Areas' folder. So let's create 'Areas' folders and also add the 'Layout' template and a few other additional configurations. Now let's create folders into our application like 'Areas\Identity\Pages\Account' , 'Areas\Identity\Pages\Shared' . Let's create a new layout for the pages inside of the 'Areas' folder. Let's create the layout file '_Layout.cshtml'. Areas/Identity/Pages/Shared/_Layout.cshtml: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="vie

Part-1 Blazor Server Cookie Authentication

In .Net applications, authentication can be simply accomplished with cookies without using any built-in authentication provider like 'Asp.Net Core Identity', 'Identity Server', 'Auth0', etc. This series is about implementing simple cookie-based authentication in the Blazor Server application. In this part of the article, we have to accomplish our targets like: Creating user authentication tables. Creating Blazor Server Application. Installing Entity Framework core. Configuring Database Context. Tables For Authentication: User - table store user information like 'email', 'password', 'firstname', 'lastname', etc. Roles - master table to store the roles like 'admin', 'user', 'manager',etc. UserRoles - a mapping table for the 'Users' & 'Roles' table to store the user roles information. Create Users Table: CREATE TABLE [dbo].[Users]( [Id] [int] IDENTITY(1,1) NOT NULL, [FirstName] [va

Use Azure Cache For Redis In AspNetCore Application Using Distributed Cache Technique[.NET6]

In this article, we are going to do a small demo on integrating Azure Redis Cache into the AspNetCore Application using Distributed cache technique. Redis Cache: Redis is an open-source in-memory data structure store, used as a database, cache. It supports data structures such as strings, hashes, lists, sets, stored sets with range queries, etc. Let's understand the flow of Redis cache in a web application: Users request a page from the web application. Web application queries the Redis store, if the data exists, then fetches the data and returns the response directly to the user. If no data is in the Redis store, the application queries the database and fetches the data, next save the same data into the Redis store so that subsequent user request can consume the data from the Redis store directly, finally returns the response to the users. Create A Azure Redis Cache: Step:1 Create and sign-in into the Azure portal( Step:2 On the Azure portal home page