|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
WebControl, WSS, SessionSessionState. and NullReferences. Somewhere, this method it throwing a NullReference Exception. It began when I added the session information. Options for null - base - not likely - worked before SS added. I think I handled the case of the empty session appropriately, if not overzealously. Is there something funky about WSS and SessionState? Or am I getting the SessionState from the wrong place? Class Declaration: public class WebQuizControl : WebControl The Method: protected override void CreateChildControls() { base.EnsureChildControls(); if ( !isConfigured ) return; object temp = null; if (! HttpContext.Current.Session.IsNewSession) temp = HttpContext.Current.Session["questionSet"]; // Does C# shortcut here? if temp == null is the castI executed? if ( temp == null || ( temp as ExamCreator ) == null ) { questionSet = new ExamCreator( Association, course, module ); // parameters are valid HttpContext.Current.Session.Add( "questionSet", questionSet ); } else // Probably not in here, as it crashes on initial load. { questionSet = HttpContext.Current.Session["questionSet"] as ExamCreator; } foreach ( Question q in questionSet.Questions ) { this.Controls.Add( q ); } // [snip] .. add submit, reset etc. } |
|||||||||||||||||||||||