Session_Start , Session_End are being called on Application Start up? RRS feed

  • Question

  • User769474054 posted

    In my ASP.NET Application, the Session_End method is firing when Application starts up. My break points in that method hits when app starts for the first time. Isn't it supposed to execute only after Session was timed out? why is this weird behavior.

    Am i missing something.

    My WebConfig is set to have timeout as 20 mins and its by default Inproc.


    Wednesday, July 15, 2015 9:39 PM

All replies

  • User465171450 posted

    Sessions can also terminate when the application recycles.

    Wednesday, July 15, 2015 10:56 PM
  • User769474054 posted

    But, when App Starts, it means recycling? 

    Am I recycling the App pool when I press ctrl+F5 on my machine to run the code of the App? What do you mean by app recycling. Can you pls  illustrate for me.



    Thursday, July 16, 2015 5:19 PM
  • User-219423983 posted

    Hi pavanlalit,

    Session End can be called when you use Session.Abandon(). You could step by step to debug when you call the abandon. The following is about firing the Session_End event conditions, you could take a look.

        1.The Session_End event only will be fired when the the mode is InProc;       

        <sessionState mode="InProc" cookieless="false" timeout="20"/>

        2.There must be something saved in the session;

        3.Session timed out or execute Session.Abandon ().

    I hope it’s useful to you.

    Best Regards,

    Weibo Zhang

    Sunday, July 19, 2015 10:01 PM
  • User753101303 posted


    Would have to check but could it be that nothing yet is stored in the session? In this case it always starts (but don't remember if session_end is called as well).

    Tuesday, July 21, 2015 2:11 PM
  • User-481631678 posted

    Session_Start is supposed to be called after Application_Start. But if Session_END is being called it means that you have called session.abandon somewhere in your code.

    Thursday, August 6, 2015 7:59 AM
  • User-474980206 posted

    on a recycle, session_end is called for all sessions created in the old app domain. generally this will called after the new app domain is setup. so if you trace you will see the new app domain, app start, session start, then shutdown of the old domain - session end, application end. note, the session end is for the old domain, using old objects.

    note: a recycle is called when the app domain times out, or too many recompiles of the source files have happened (controlled by web.config settings)


    Sunday, August 23, 2015 1:42 PM