ASP.NET forms authentication - auto login with a test account while debugging?

asp.net, asp.net-membership

Solution

This code does the job. In Login.aspx's Page_Load event:

    Membership.ValidateUser("<userName>", "<password>")
    FormsAuthentication.RedirectFromLoginPage("<userName>", True)

MSDN Documentation

Note: `Membership` uses the `System.Web.Security` reference.

Problem

I have a web application that uses the asp.net membership and role providers to allow logins that are members of certain roles to have access to various pages depending on role assignments. During debugging I'd like the app to log in automatically with a test account, so I can check the functionality of the role assignments, and not have to go through entering credentials on the login page each time. Is there an easy way to do this?

Original source