Skip Navigation Links
MAIN
RESUME
IMAGE GALLERIES
ABOUT ME
OTHER STUFF
  Thursday, August 28, 2008  
Skip Navigation Links

ASP.NET ViewState Explained

clock March 7, 2008 20:44 by author Troy

While doing some research for something I was working on, I came across this blog about ASP.NET and the Viewstate.  This is a must read for those who are somewhat familiar with the viewstate and those who believe they know it all.   

http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx

The following are some points that I took away from the article:

  • an ASP.NET control will automatically restore entered/selected values even if the ViewState is DISABLED!  (wait, what? I thought that is what the ViewState was for?)
  • the Viewstate is typically only required for simple controls if the controls will be hidden between post backs (otherwise, see point above)
  • if you databind your control on each request in the OnInit event, you can disable the ViewState and the control will still automatically restore entered/selected values

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


IIS 6 on a Development box and Premature Session End

clock January 13, 2008 17:32 by author Troy

I started working on a legacy web application that was comprised of both classic ASP and ASP.NET.  The development box was running win 2003 server x64 with IIS 6. 

The application typically uses the standard 20 minute session timeout period, however, for my dev box, I wanted to lengthen that time to avoid having to log in more times than necessary.  I set the classic ASP session to 240 minutes, and the ASP.NET session to 240 minutes in the web.config file.

I then proceeded to go to work.  A short time later, I was redirected to the login page.  Hmm, wierd I thought.  Ah, let it go this time.  Log in and keep working.

The next day, after my initial log in, once again my session timed out after about 40 minutes and I was redirected to the login page.  I double checked my session times, both were still set to 240 minutes.

After a little bit of head scratching, I found my way into the properties of the Application Pool for my web app in IIS.  My attention was drawn to the Recycling tab where I noted that my application pool would be recycled every 1740 minutes.  Since my sessions were stored "In Process", this recycling would kill my session, however, the timing didn't seem too likely.  Nonetheless, I changed the property to configure the worker process to recycle at a specifiec time instead:  3am.

On the Performance tab, I found something even more interesting.  An "Idle Timeout" setting that was set to shutdown the worker process after being idle for 20 minutes.  Bingo!

So even though my session timeouts were set correctly at 240 minutes, I could still lose my session after 20 minutes because the worker process would be shut down after 20 minutes of inactivity... which might be common on a development machine where you are the only web site visitor and you are distracted by other work or working in other applications for a period of time.

Once I turned off the "Idle Timeout" feature for my Application Pool, my premature session death is a thing of the past.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


blog.TroyFarrell

About the author

Troy Farrell

E-mail me Send mail
Troy Farrell
I am a software architect and computer programmer living in Peterborough, Ontario, Canada.

Search

Calendar

<<  August 2008  >>
SuMoTuWeThFrSa
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

Archive

Tags

Categories


Blogroll

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway. In fact, if I was agitated at the time, they may not reflect my own personal opinions.

© Copyright 2008

Sign in

© Copyright Troy Farrell 2008