Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lee Engleston 3 posts 23 karma points
    Dec 09, 2013 @ 12:04
    Lee Engleston
    0

    How to use SQLServer SessionState database in Umbraco?

    My custom sessionstate database (SQL Server) is not being populated when the sessionstate configuration is setup in the Umbraco site web.config.

    I think it is because Session_Start is not firing!?

    Can anyone tell me how to implement Session_Start in Umbraco in Global.asax !? SQLServer session database not working..

    SessionState Connectionstring is fine as it works on a blank web application so it must be how Umbraco handles Session_Start (or doesn't!)

    I'm using Umbraco 6.1.2.

    Thanks

    -- Lee

  • Simon steed 359 posts 668 karma points
    Dec 09, 2013 @ 12:29
  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Dec 09, 2013 @ 12:32
    Sebastiaan Janssen
    0

    I think this will help: http://stackoverflow.com/questions/15872770/global-asax-in-umbraco-6

    Basically:

    • Make a class that inherits from Umbraco.Web.UmbracoApplication
    • Implement Session_Start
    • Change your Global.asax file to point to the new class you made

    Example:

    using System;
    
    namespace My.Namespace
    {
        public class Global : Umbraco.Web.UmbracoApplication
        {
            protected void Session_Start(object sender, EventArgs e)
            {
                //Do your thing
            }
        }
    }
    

    Global.asax should then look like this:

    <%@ Application Codebehind="Global.asax.cs" Inherits="My.Namespace.Global" Language="C#" %>
    
  • Lee Engleston 3 posts 23 karma points
    Dec 09, 2013 @ 12:32
    Lee Engleston
    0

    Yes but Session_Start still doesn't get called. Any ideas?

    -- Lee

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Dec 09, 2013 @ 12:36
    Sebastiaan Janssen
    0

    @Lee What exactly have you done? Example code please?

  • Lee Engleston 3 posts 23 karma points
    Dec 09, 2013 @ 12:40
    Lee Engleston
    0

    Ahh.. I think that may be the issue (I didn't write this code)..

    I had this..

    using System;
    
    namespace My.Namespace
    {
        public class Global : Umbraco.Web.UmbracoApplication
        {
            protected void Session_Start(object sender, EventArgs e)
            {
                //Do your thing
            }
        }
    }
    

    But my Global asax was

    <%@ Application Codebehind="Global.asax.cs" Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %>
    

    Instead of

    <%@ Application Codebehind="Global.asax.cs" Inherits="My.Namespace.Global" Language="C#" %>
    

    Session_Start now firing!! yey!

    Cheers guys!

    -- Lee

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies