Solved

Global.asax file

Posted on 2006-07-10
4
899 Views
Last Modified: 2012-05-05
Hi,

I am starting to use the global.asax file, as I have never touched on it before. I successfuly increment an application value when a session starts, but when a session ends, I subtract one from this value. The Session End process is not firing, and the value just keeps increasing. Please could some one advise.

Thanks in advance

Andrew

P.s. My Code

<%@ Application Language="C#" %>

<script runat="server">

   
    void Application_Start(object sender, EventArgs e)
    {
        Application["NoUsers"] = 0;
        // Code that runs on application startup

    }
   
    void Application_End(object sender, EventArgs e)
    {
        //  Code that runs on application shutdown
        Application["NoUsers"] = Convert.ToInt32(Application["NoUsers"]) - 1;
    }
       
    void Application_Error(object sender, EventArgs e)
    {
        // Code that runs when an unhandled error occurs
        Application["NoUsers"] = Convert.ToInt32(Application["NoUsers"]) - 1;
    }

    void Session_Start(object sender, EventArgs e)
    {
        Application["NoUsers"] = Convert.ToInt32(Application["NoUsers"])+1;
        Response.Write(Application["NoUsers"].ToString());
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e)
    {
        Application["NoUsers"] = Convert.ToInt32(Application["NoUsers"]) - 1;
        // Code that runs when a session ends.
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer
        // or SQLServer, the event is not raised.

    }
       
</script>
0
Comment
Question by:REA_ANDREW
  • 2
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17071634
Are you actually waiting long enough for the sessions to expire when testing ?
0
 
LVL 20

Author Comment

by:REA_ANDREW
ID: 17071639
Does the session automatically end when a browser window is shut?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 17071652
Nope. It ends after whatever period is specified in the session timeout, by default this is 20 minutes.
0
 
LVL 20

Author Comment

by:REA_ANDREW
ID: 17071666
Right, thanks for that, much appreciated
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now