Solved

Global.asax file

Posted on 2006-07-10
4
903 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 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