Forms Authentication - how to read timeout?


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
 
Ad

Advertisements

M

miher

Hi,

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

Hope You find this useful.
-Zsolt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top