Since .NET Framework 2.0 appeared, Microsoft is providing different membership providers to deal with authentication. Those providers give you great flexibility and customization but when you indeed need that higher grade of customization, they come with few costs: long time of implementation and a lot of code to manage.
In this tutorial I will show you how to build from scratch a fully functional role-based authentication system with only a few lines of code. However, for simple login systems, I strongly recommend using the default membership provider from ASP .NET.