To access the properties and modify the properties of FormsAuthentication from code behind, use following code snippet.
// Get the Web application configuration.
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration("/aspnetTest");
// Get the external Authentication section.
AuthenticationSection authenticationSection =
(AuthenticationSection)configuration.GetSection(
"system.web/authentication");
// Get the external Forms section .
FormsAuthenticationConfiguration formsAuthentication =
authenticationSection.Forms;