Copied to clipboard

Flag this post as spam?

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


  • Asif Malik 203 posts 339 karma points
    Jan 22, 2013 @ 13:24
    Asif Malik
    0

    Wiring into session events

    Hi I am trying to wire into the Session)Start and Session_End events using Umbraco 4.11. I have implemented IApplicationEventHandler but cant figure out how to wire up the event.

    Any guidance would be appreciated

  • Asif Malik 203 posts 339 karma points
    Jan 22, 2013 @ 18:05
    Asif Malik
    0

    After a little more digging around i have added the following 

                var session = httpApplication.Modules["Session"as SessionStateModule;
                session.Start += new EventHandler(session_Start);
                session.End += new EventHandler(session_End);
    

    i have tried this in all 3 methods OnApplicationStarting, OnApplicationStarted and OnApplicationInitialized but the methods never get called. additionally i have added the following to the web config file in the system.webServer > modules area

                    <remove name="Session" />
                    <add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition="" />
    

    If anyone has any thoughts or guidance it would be greatly appreciated

  • Asif Malik 203 posts 339 karma points
    Jan 22, 2013 @ 18:31
    Asif Malik
    0

    Have kinda got this working but am not happy with the hack and dont know if it will cause any adverse effects, woudl appreciate if someone could comment on whether this is bad ... or indeed how bad it is.

    I have added the following code to the Global.asax file and with breakpoints on it goes into these 2 methods.

    <script language="C#" runat="server">
    public void Session_OnStart() {
         // some code here 
    }
    public void Session_OnEnd() 
    {
         // some code here
    }
    <script>
  • Asif Malik 203 posts 339 karma points
    Jan 23, 2013 @ 10:37
    Asif Malik
    0

    Hi I am hoping to get some guidance (ideally from the core team) as to the correct way to do this, any help would be appreciated

  • Remco 4 posts 24 karma points
    Feb 22, 2013 @ 11:43
    Remco
    0

    I am having the same issue.

    Throughout the several Umbraco versions there have been made a lot of changes, at least this is the idea I get when searching for answers (googe).

    Solutions range from delete a dll / inheriting global or application objects (both umbraco). All of those 'answers' regarding umbraco 4.x

    What I really would love to see is a bit of help here and hopefully a solution for both Asif Malik and me regarding Session_Start events in 4.11

    After that, for god sake, stick to a (any) plan for a couple of years.

     

  • Asif Malik 203 posts 339 karma points
    Feb 22, 2013 @ 13:41
    Asif Malik
    0

    Hi Remco, if you want a temporary solution then i would advise you to edit the relevant event in the Global.asax file as mentioend above.

    Asif

  • John 10 posts 161 karma points
    Apr 03, 2014 @ 12:45
    John
    0

    This code posted earlier appears to be the correct way to do this.

    According to this thread over at the asp.net forums, Global.asax is the correct place to wire into the session events, not (SessionStateModule)(httpApplication.Modules["Session"]).Start and (SessionStateModule)(httpApplication.Modules["Session"]).End. Emphasis mine:

    IIRC, the 4 event handlers (App_Start, App_End, Session_Start, Session_End) are all "special" event handlers and global.asax is the only place you're allowed to have them.

    Excuse the necromancy, I thought it might be helpful for other people in the future.

Please Sign in or register to post replies

Write your reply to:

Draft