WebControl, WSS, Session

Discussion in 'ASP .Net Web Controls' started by chris, Nov 22, 2007.

  1. chris

    chris Guest

    'm having some problems with a WebControl, Sharepoint and
    SessionState. 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.
    }
     
    chris, Nov 22, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john
    Replies:
    0
    Views:
    347
  2. Kannan

    Upload files to a folder in WSS

    Kannan, Mar 7, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,532
    Kannan
    Mar 7, 2004
  3. Shikari Shambu
    Replies:
    2
    Views:
    471
  4. laks
    Replies:
    0
    Views:
    453
  5. Sven W.
    Replies:
    1
    Views:
    173
    Bob Barrows [MVP]
    Jan 20, 2008
Loading...

Share This Page