Forms Authentication - how to read timeout?

  • Thread starter Thread starter Thomas
  • Start date Start date
T

Thomas

Hello developers.

I have the following web.config section:

<authentication mode="Forms">
<forms slidingExpiration="true" loginUrl="~/Login.aspx" timeout="30" />
</authentication>

On my Login.aspx form, if login succeeds, I create FormsAuthenticationTicket
in code like this:

tkt = new FormsAuthenticationTicket(1, userName, DateTime.Now,
DateTime.Now.AddMinutes(30), false, "");

The question: how do I read the timeout value from the web.config
authentication/forms element so it does not have to be hardcoded? I was
looking among FormsAuthentication properties, but found nothing useful.

Thank you for any hints.

Thomas
 
Hi,

You can use the WebConfigurationManager.
AuthenticationSection auth =
WebConfigurationManager.GetSection("system.web/authentication") as
AuthenticationSection;

Hope You find this useful.
-Zsolt
 
Back
Top