Posts

Using TempData and Creating Custom Exception Filter in ASP.NET Core 3.1

Image
The exception handling in Web application is the most important part. Exception Handling must be implemented so that if the the HTTP request processing is failed on the server and exception occurred then the error page with required error must be shown to the user.    Filters in ASP.NET Core In ASP.NET Core, Filters allows code to before or after specific stages in the request pipeline are executed e.g. OnActionExecuting and OnActionExecuted().  We have standard filters like Authorization and ResponseCaching. We can add custom filters in the request pipeline for additional operations e.g. Exception Handling, Custom Authorization, etc. The following figure will explain  filter execution in ASP.NET Core 3,1 application  Figure 1: The Filter Execution As shown in the above figure, filters are executed in MVC application pipeline. This means that when MVC controllers are requested the filters will be loaded in the pipeline and they are executed as per t...

Authenticating Angular 8 Client Application with JSON WEB Token (JWT) Based Authentication

Image
In my  previous article we have seen the Token based authentication using ASP.NET Core 3.1. In continuation of that post, in this post we will demonstrate the Authentication of the Angular application. Angular is one of the most preferred framework for modern front-end applications. Angular uses the http module from @angular/common package to make HTTP Calls to external REST APIs.  Angular uses HttpInterceptor interface. This interface intercepts and handles Httprequest and HttpResponse. The interceptor transforms the outgoing request by adding addition information into the HTTP headers e.g. Token information. To authenticate the client application using JSON Web Token we need to register new users using the authentication service and then authenticate the user to receive JSON Web Token from the server side application. The client application uses this token to make requests to the server and  the server authenticate the requests from the client application based on ...

Understanding Token Based Authentication in ASP.NET Core 3.1 using JSON WEB TOKENS

Image
In this post we will discuss the Token Based Authentication in ASP.NET Core 3.1.  Security is one of the backbone for modern web application development. In most of the Modern Web Applications the security is implemented using JSON Web Tokens.  What is JSON Web Token? JSON Web Token (JWT), is an open standard, self-defined and compact mechanism for securely transmitting information across parties using JSON object. Since the token carries digital signature, the information in transmission is verified and trusted. The signature can be generated using HMAC algorithm or using public/private key pairs using RSA. The Signed token can be used to verify integrity of claims contained within it. The claim are the entities contained in the token e.g. user, roles, etc. When can we use JSON Web Tokens? We can use JSON Web Tokens in case of following scenarios Authorization:   This is the frequent scenario of using JWT in modern applications. When the user log...