Copied to clipboard

Flag this post as spam?

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


  • Chris Knowles 141 posts 222 karma points
    May 07, 2014 @ 14:17
    Chris Knowles
    0

    Umbraco 7 - Global.asax

    I am trying to figure out how, in umbraco 7, to add session variables to session_start?

    I have done a fair bit of searching and I can't see to find anything that works.

    Can someone help me please? Thanks

    Chris

  • Dan Lister 416 posts 1974 karma points c-trib
    May 09, 2014 @ 11:52
    Dan Lister
    103

    Sounds like you'll need to create your own Global Application class which inherits from Umbraco Application. From there you'll be able to access session events as per the usual global way. Try the following:

    <%@ Application Codebehind="Global.asax.cs" Inherits=“MyApplication.Global" Language="C#" %>
    
    using System;
    using Umbraco.Web;
    
    namespace MyApplication
    {
        public class Global : UmbracoApplication
        {
            protected void Session_Start(object sender, EventArgs e)
            {
                // Session start logic here
            }
        }
    }
  • Chris Knowles 141 posts 222 karma points
    May 09, 2014 @ 12:15
    Chris Knowles
    0

    Hi Dan,

    Thanks for your answer, just to be clear does that code need to go into the asax page itself or a new class called global.asax.cs?

    Thanks Chris

  • Dan Lister 416 posts 1974 karma points c-trib
    May 09, 2014 @ 12:25
    Dan Lister
    0

    You'll need to add the second code snippet to a new class file. The first goes in global.asax.

Please Sign in or register to post replies

Write your reply to:

Draft