
Authentication Methods | 195
ASP.NET
Security
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Forms Authentication
Forms authentication is probably the most useful built-in ASP.NET authen-
tication module because it provides a very flexible infrastructure for roll-your-own
security scenarios. When an application is configured to use Forms authentica-
tion, requests for protected resources are redirected to a specified login page,
unless the request is accompanied by an authentication token contained in a
cookie. For more information on protecting resources when using Forms authen-
tication, see “Authorization,” later in this chapter.
Logging in
In the login page, the site developer writes code to check the credentials entered
by the user against a backend credentials store. This store can be a relational data-
base such as SQL Server, an XML file, Microsoft Active Directory, or any other
storage location of your choice. If the credentials match those stored in the
backend credential store, the developer calls the RedirectFromLoginPage method
of the
FormsAuthentication helper class to send the user back to the page that they
originally requested and to set either a session cookie or a persistent cookie
containing the authentication token on the user’s machine. Once the user is
authenticated, he or she can access other resources in the