This documentation is archived and is not being maintained.

FormsAuthentication.EnableFormsAuthentication Method

Enables forms authentication using the specified configuration data.

Namespace:  System.Web.Security
Assembly:  System.Web (in System.Web.dll)

public static void EnableFormsAuthentication(
	NameValueCollection configurationData


Type: System.Collections.Specialized.NameValueCollection
The configuration data to use for forms authentication.


The method was called from the Application_Start method in the Global.asax file, or after that method.

This method enables you to enable forms authentication programmatically instead of by using Web.config file settings. You can provide the following settings in the configurationData parameter:

  • defaultUrl

  • loginUrl

This method can be called multiple times, but after it has been called, the setting cannot be reverted (that is, forms authentication cannot be disabled). If the method is called multiple times with different settings, the settings provided in the last call take precedence.

This method must be called before the Application_Start method in the Global.asax file is called. For example, you can call this method from the PreApplicationStart method. For information about the PreApplicationStart method, see PreApplicationStartMethodAttribute.

.NET Framework

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.