i

ASP.Net A Complete Guide

Forms Authentication

As the name suggests, we enter the credentials through the login form. The user submits those details, and credentials are validated against that are stored in the database. If those are the valid credentials, then the only user can make an entry in the web application.

For this authentication, we need to set the mode in the web application's web.config file. The mode is used to identify that this web application will use the form authentication or the windows authentication

Syntax:

We need to set the login form details as well in the web.config file.

If the user is not valid, it means credentials are not as per the database we can redirect a user to the error page. For redirecting the user to the error message, we need to set the error page, and for the page, we also need to add the entry in the web.config file.

An ASP.NET page raises a number of events during its lifecycle:

  • One event raised when the request is being authenticated and authorized.

  • The second event raised in the case of an unhandled exception, and so forth.

HTTP Modules classes:

These classes execute in response to a particular event in the request lifecycle.

FormsAuthenticationModule – This module helps in authenticating a user by inspecting the forms authentication ticket. If no authentication ticket is present, the user is anonymous.

UrlAuthorizationModule – Identifies that the current user is authorized to access the requested URL.