HttpContext.Current.Session is Null in StateProvider

  1. #1

    HttpContext.Current.Session is Null in StateProvider

    Hi,

    I am getting an exception from within the Coolite StateProvider when using SQL out-of-process session states. My application is merely performing a Server.Transfer to a default error page, but it actually fails performing this step. Looking at the stack trace, it's failing within the Coolite toolkit at the location stated below.

    After some Googling, I've determined that it could be any of the following reasons:

    1. Breaking change in .NET 3.5 which could be fixed by SP1 (it didn?t, at least not on my machine)
    2. Something that could be fixed by running IIS7 and turning on integrated pipeline mode (I?m on XP, so no IIS7)
    3. Something totally different and this is a red herring.

    Has anybody encountered this particular problem?


    public virtual StateProvider StateProvider
            {
                get
                {
                    if (this.stateProvider != null)
                    {
                        return (StateProvider)this.stateProvider;
                    }
    
                    if (this.IsMVC && (this.stateProvider == null || (StateProvider)this.stateProvider == StateProvider.PostBack))
                    {
                        this.stateProvider = StateProvider.None;
                        return (StateProvider)this.stateProvider;
                    }
    
                    if (!this.DesignMode)
                    {
                        string token = "Coolite.StateProvider";
    
                        object obj = HttpContext.Current.Application[token];
    
                        if (obj == null)
                        {
                            obj = HttpContext.Current.Session[token];  <- Exception occurs here. Session is null.
                        }
    
                        if (obj != null &amp;&amp; obj is StateProvider)
                        {
                            this.stateProvider = (StateProvider)obj;
                            return (StateProvider)this.stateProvider;
                        }
                    }
                    else
                    {
                        this.stateProvider = WebConfigUtils.GetStateProviderFromWebConfig(this.Site);
                        return (StateProvider)this.stateProvider;
                    }
    
                    this.stateProvider = GlobalConfig.Settings.StateProvider;
                    return (StateProvider)this.stateProvider;
                }
                set
                {
                    this.stateProvider = value;
                }
            }
  2. #2

    RE: HttpContext.Current.Session is Null in StateProvider

    If it helps, we are using Coolite 0.7 with SQL Server 2008 with sql session states.
  3. #3

    RE: HttpContext.Current.Session is Null in StateProvider

    Hi tze,

    Are you building the controls from the Community source? If yes, what happens when you comment out that line and retest?


    We can change the source to ensure Session is != null, but the fix would not be made public until the v0.8 release.


    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] Problem with HttpContext.Server.Transfer
    By xeo4.it in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 14, 2011, 2:52 PM
  2. [CLOSED] ToScript() requires HttpContext
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 10, 2010, 4:50 AM
  3. Replies: 1
    Last Post: May 19, 2009, 7:30 AM
  4. TreePanel and StateProvider
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 0
    Last Post: Jan 04, 2009, 1:14 AM
  5. Cookie StateProvider
    By Timothy in forum 1.x Help
    Replies: 0
    Last Post: Jun 26, 2008, 6:02 PM

Posting Permissions