Form Authentication in MVC 5: Part 1

Introduction

This is Part 1 of Form Authentication in MVC 5.

In this article we will learn what Authentication and Authorization is 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 that 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 rights to use that is nothing but Authorization.

DEMO

Register Page

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



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



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



Login Page

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



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.



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 login, the Login and Register link will be replaced by a Logout link.



Summary

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

I hope you like this.

Thank you.