Use Forms Authentication

Problem

You want to prevent users from accessing certain pages unless they have first authenticated themselves with a custom login page.

Solution

Implement forms authentication. You must create the login page, but ASP.NET keeps track of a user’s authentication status.

Discussion

Forms authentication is a flexible security model that allows you to prevent unauthenticated users from accessing certain pages. You write the code that performs the authentication, and ASP.NET uses a cookie to identify authenticated users. Users without the cookie are redirected to a login page when they try to access a secured page.

To implement forms authentication, you must take these steps:

  1. Configure forms authentication using the <authentication> ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.