How to change SlidingExpiration property of FormsAuthentication programmatically?

Raja
Posted by Raja under ASP.NET category on | Views : 6702
To change the SlidingExpiration property of FormsAuthentication programmatically, 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;

// Get the current SlidingExpiration.
bool currentSlidingExpiration =
formsAuthentication.SlidingExpiration;

// Set the SlidingExpiration.
formsAuthentication.SlidingExpiration = false;

Comments or Responses

Login to post response