Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6871367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:47:50+00:00 2026-05-27T03:47:50+00:00

I’ve implemented a custom ASP.NET session timeout control derived from a control by Kenneth

  • 0

I’ve implemented a custom ASP.NET session timeout control derived from a control by Kenneth Scott. It’s hosted by IIS7 in .NET 4.

Long story short, it’s a server control (implementing System.Web.UI.WebControls.WebControl) that I include in my site master page. The control is invisible, and starts a timer when a page is rendered. After X minutes have passed, a DIV is displayed telling the user their session is timing out, and offers them a button to click if they want to stay logged in.

Clicking the button just fires a standard postback to the server. It doesn’t perform any useful work on the server, except for resetting the sliding expiry for the session.

The timeout control is configured to kick in a minute before the session should expire. When it reaches 0, the session should also be expiring, and I redirect the user to the login page and notify them that they timed out due to inactivity.

It works great the majority of the time, but sometimes “doesn’t work”. The button still appeared to work to users, but after trying to click any other control on the site, they immediately get dumped to the login page (standard ASP.NET behaviour defined in web.config).

I added some logging statements to the click event handler and discovered that it’s not firing. My assumption here is that the client is sending a request to the server, but since the session is expired, my event handler never fires.

I’m confident my app pool isn’t getting recycled (it’s configured to recycle once daily, and no processes or sticky-fingered admins are editing files in the application directory). This failure is happening intermittently. We’re using Forms authentication.

My system.web section in web.config:

<sessionState mode="InProc" timeout="20" />
<authentication mode="Forms">
  <forms path="/" loginUrl="Pages/LoginPage.aspx" protection="All" timeout="20" slidingExpiration="true" />
</authentication>

My workaround for the moment has been to increase our session and forms timeout to 30 minutes, and introduce a new configuration setting for the timeout, which still logs the user out after 20 minutes. That extra 10 minutes provides enough padding that my control works as expected.

I dislike the solution because it’s a workaround at best. I feel like I don’t understand the ASP.NET session timeout mechanism adequately (despite having read and reread the MSDN documentation). Can anyone explain the behaviour I’m seeing, or maybe point out any bad assumptions I’m making?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:47:51+00:00Added an answer on May 27, 2026 at 3:47 am

    You could try to log any application-endings and the reason for ending, just to rule out it has anything to do with that. I always use this script for that (just put it in the global.asax):

    protected void Application_End()
      {
         Type httpRuntimeType = typeof (HttpRuntime);
    
         HttpRuntime runtime =
            (HttpRuntime)
            httpRuntimeType.InvokeMember("_theRuntime", BindingFlags.NonPublic
                                                        | BindingFlags.Static |
                                                        BindingFlags.GetField,
                                         null, null,
                                         null);
    
         if (runtime == null)
            return;
    
         string shutDownMessage =
            (string) runtime.GetType().InvokeMember("_shutDownMessage",
                                                    BindingFlags.NonPublic
                                                    | BindingFlags.Instance
                                                    | BindingFlags.GetField,
                                                    null,
                                                    runtime,
                                                    null);
    
         string shutDownStack =
            (string) runtime.GetType().InvokeMember("_shutDownStack",
                                                    BindingFlags.NonPublic
                                                    | BindingFlags.Instance
                                                    | BindingFlags.GetField,
                                                    null,
                                                    runtime,
                                                    null);
    
         EventLog log = new EventLog();
         log.Source = ".NET Runtime";
         log.WriteEntry(
            String.Format(
               "\r\n\r\n_shutDownMessage={0}\r\n\r\n_shutDownStack={1}",
               shutDownMessage,
               shutDownStack),
            EventLogEntryType.Information);
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a bunch of posts stored in text files formatted in yaml/textile (from
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.