How do I set a session timer / timeout in C# codebehind?

Posted on 2014-09-25
Last Modified: 2014-10-06
Are there any examples that I can see here or be pointed to to show how to set the session timeout for my web application in the code behind? (C#)?
Question by:mikesExpertExchange
  • 2
LVL 25

Expert Comment

ID: 40346825
You can set the timeout in the web.config or in the code. Please see more details in this link,

Author Comment

ID: 40346880
@apeter: that shows me and example for the web.config and that helps. I also need an example in C#?
LVL 78

Accepted Solution

David Johnson, CD, MVP earned 500 total points
ID: 40348109
int iTimeout = 10; // 10 minutes
HttpSessionState.Timeout  = iTimeout;

Author Closing Comment

ID: 40364097
Thank you.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now