Form Authentication in MVC 5: Part 1

Introduction

In this article, we will learn what Authentication and Authorization are with a small demo of what we will accomplish by the end of this series.

Authentication

Authentication is giving access to the user for a specific service by verifying his/her identity using his/her credentials like username and password or email and password. It assures that the correct user is authenticated or logged in for a specific service and the right service has been provided to the specific user based on their role which is nothing but authorization.

Authorization

Once a user is authenticated, a specific service is provided to them based on their role. For example, Admin will be treated differently for a service and the user will be treated differently for a service.

There are some services in an application that only an admin has the right to use that are nothing but Authorization.

Demo

We will have two links that will redirect us to the Login and Register page.

Register page

If we try to create more than one user with the same username, we will get a validation error message.

Validation error message

If we specify a unique username and password, the password will be stored in an encrypted format.

Unique username

Login Page

On the Login page, if we enter an invalid username or password, we will get a validation error message.

Invalid username

If we try to navigate to the About section of this application without specifying the credentials, we will be redirected back to the Login page.

About section

If we specify a valid credential, we will be redirected to the About section, and in addition to that, we will even show the user name at the top-right corner.

Once we log in, the Login and Register link will be replaced by a Logout link.

 Register link

Summary

This is just a glimpse of what we will learn in future articles of this series. So stay tuned for more.

I hope you like this.

Thank you.


Similar Articles