Skip to main content


Showing posts with the label Asp.Net

Part-2 Create A Microservice For The Products Endpoint[.NET6 Microservice Series]

In this article, we will create a microservice application that contains the product endpoint. So creating a microservice means the application contains endpoints related to a specific module or component. So here I'm going to create 2 endpoints like HTTP GET, HTTP Post for the products to accomplish our demo. (We can implement the entire CRUD operation endpoint if we want). Click here for Part-1 of the .NET6 Microservice Series . Create A .NET6 Web API Application: Let's create our first microservice application with .NET6 Web API application. Let's name our microservice project as 'Manufacture.Api'. To create .NET6 application recommended IDE's are Visual Studio 2022', 'Visual Studio Code'. In this demo, I'm using .NET CLI and Visual Studio Code editor. CLI command dotnet new webapi -o Your_Project_Name Install NuGet Packages: Install EntityFramework Core NuGet. .NET CLI command dotnet add package Microsoft.EntityFrameworkCore --ve

.NET6 Razor Pages CRUD Operations With Entity Framework Core

In this article, we will do a small demo of the AspNetCore 6 Razor Pages CRUD operation. Razor Pages: Razor Page is a simplified web application model. On comparing with the 'MVC' template, razor pages won't have 'Controller', which means Razor Page is a combination of 'View' and 'Model'. Routing itself is configured within the page or view. A Razor Page mostly contains 2 files like '*.cshtml'(View) and '*.cshtml.cs'(model). Create A .NET6 Razor Pages Application: Let's create a .Net6 Razor Page sample application to accomplish our demo. We can use either Visual Studio 2022 or Visual Studio Code(using .NET CLI commands) to create any.Net6 application. For this demo, I'm using the 'Visual Studio Code'(using the .NET CLI command) editor. CLI command dotnet new webapp -o Your_Project_Name Let's explore the project to understand its structure: (1) Let's understand the initial services registered in 'Progr

Refresh Token For JWT(JSON Web Token) On Authenticating .Net Core Application

In  Part-1 .Net Core Authentication Using JWT(JSON Web Token) , we have discussed step by step implementation about generating authentication token using JWT(JSON Web Token). Now we will discuss the generation of refresh token and using refresh token we will fetch authentication token again on its expiration. This article will be the continuation of  Part - 1 . RandomNumberGenerator Instance: System.Security.Cryptography.RandomNumberGenerator will be used to generate a random number which will be used as a refresh token. Note: It is not a mandatory approach to use 'System.Security.Cryptography.RandomNumberGenerator'. You can use your own some secured technique to generate a unique token string or you can use GUID. Generate Refresh Token: Let's add a private method that returns a random unique key that we can use as a refresh token. Logic/AccountLogic.cs: private string GetRefreshToken() { var key = new Byte[32]; using (var refreshTokenGenerator = RandomNumberGenerator.C

Part 2: Share Authentication Cookie - Application Runs Under Another Application

Introduction: In  Part-1  we have implemented SSO with sharing authentication cookie between domain and subdomain binds to an MVC application. Now we implement the sharing authentication cookie between two different applications which runs under another application in IIS Server. For example, ASP.NET Core MVC application is client application shares login cookie to the ASP.NET Core WEB API which is hosted under the MVC application as a child in IIS Server.  To know more about child application runs under another application click here Core Concept: Sharing authentication Cookie between entirely two different applications, but one application runs under other applications in IIS. Create an MVC Application:  Create an MVC application by following  Part-1 , consider it is the main application for registering users and log-in to the application. Create WEB API Application: Now we have to create another application, which runs under the MVC application(created by following Step 1

Part 1: Share Authentication Cookie - SSO (Single Sign-On) In Dotnet Core

Introduction: Single Sign-On (SSO) is an authentication technique where the user uses one set of login credentials to access multiple web applications. About Platform: . core MVC . Microsoft Identity Login . Dotnet core 2.2 . SQL LocalDB Core Concept: In the dotnet core, by sharing authentication cookie we can achieve SSO for the subdomains. A subdomain is a domain which part of another domain.  Additional name prefixed to a domain that URL can be a subdomain. For example " " is a domain, its subdomain looks like " ". Create MVC Application & LocalDB Setup To IIS & IIS Hosting: Create an MVC Core application by selecting a login individual user template from a visual studio. For this application use, LocalDB as a database then host this application to local IIS, bind "" as domain and "" as a domain to test

IIS Server Sub Application Hosting Or Folder Level Hosting

Introduction: In IIS Server so many numbers of applications can be hosted as child applications under one main application. Domain bindings did at the main application, the same domain can be used by child application with their folder path as URL. Let say the "" domain is assigned to the main application. Under it, child application hosted in a folder like "api" now it can be accessed with the URL "" Step 1: Let host main application, open "Internet Information Services (IIS) Manager" goto  "Sites" right-click on it and select "add new website" a popup get open as follows . "Site Name" application name in IIS . "Physical Path" location of application source code . "Host Name" domain that configured to the application Step 2: Click ok our application created and hosted in IIS Server it looks as below Now we have our main