Skip to main content

Posts

ASP.NET Core Web API Versioning

Introduction: An iteration and evolutionary changes of an ASP.NET Core Web API is handled by Versioning. Versioning of an API gives confidence to the clients which consumes API for a long time. Any changes or development of an API will be accessible using the new version and it won't cause issues to the clients consuming the old version of API. When To Use Versioning: Any API response changes. Developing an API by implementing testing levels like 'Alpha', 'Beta', and 'RC' versions before releasing Production. Deprecating an API which means API going to be removed or upgraded by a version within a short period. Versioning Types: Query String Versioning Url Path Versioning Media Type Versioning API Version Nuget: To Configure versioning to AspNet Core Web API Microsoft provided a library(Microsoft.AspNetCore.Mvc.Versioning). So to use the versioning library please install NuGet below.              Install-Package Microsoft.A

Angular State Management With NgRx

Introduction: NgRx framework helps Angular to develop more reactive applications. NgRx provides state management to an application, where data of an application is stored at a single place and then supplied throughout the application where ever needed. Using NgRx if data is updated, all the components consuming that data get updated instantly. Benefits of using NgRx with Angular application like Serializability, Type Safety, Encapsulation, Testable, and Performance. Key Features: NgRx framework key features like Store: A  s tore is a data place where all the application related information stored and supplied to the Angular components on demand. Reducer: A reducer is a pure function based on Actions it returns the new state. Actions: An action expresses an event of an application, that causes a change in the state of the application. Selector: A selector is a pure function that obtains a slice of data from the store. Effects: An Effect is to isolate components f

Dotnet Core MVC Cookie Login Sample Role-based Authorization (Part 2)

Introduction: Authorization means an authenticated user having permission to access specific protected resources. In general, Authorization can be called special permissions. For example in an application, an admin user has all permission to modify the application, a non-admin user might have permission likes read-only content in the application. In the  first article , we have discussed the Cookie-Based login mechanism. This will be a continuation article, here we discuss Authorization. Note: Before reading this article, read  Dotnet Core Cookie Login Sample (Part 1) . Pages Controller: Now add a new controller name as 'PagesController.cs' and to this controller add 3-action methods to show 3 pages in the application. PagesController.cs: namespace CookieAuth.Web.Controllers { [Route("pages")] public class PagesController : Controller { [Route("admin")] [HttpGet] public IActionResult Admin() {

Dotnet Core MVC Cookie Login Sample From Scratch(Part 1)

Introduction: In general ASP.NET Core applications(MVC, RazorPages, WebAPI, Blazor Server Side) use login libraries like ASP.NET Core Identity , IdentityServer4 , OAuth 2.0 , etc. But ASP.NET Core can simply implement login with using Cookie-Based Authentication  without any login libraries. ASP.NET Core Identity  is a membership program that helps to create a login functionality. Its rich library with all default login functionalities, creating users, adding roles, password encryption, and support to social logins like Google, Facebook, Outlook, Twitter, etc. IdentityServer4 Or OAuth 2.0  is the latest login technology. It also gives all login functionalities and support to social logins as well additionally Single Sign-On and   Token-Based user login. Cookie-Based Authentication  is a default login mechanism provided by ASP.NET Core applications. But user creation, adding roles need to be done manually which is not hard to do. In this approach, we don't