How to access FormsAuthentication section from Code behind in ASP.NET?

Raja
Posted by Raja under ASP.NET category on | Views : 3916
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;

Comments or Responses

Login to post response