473,385 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

2.0: Global.asax simple problem

Hello,
Could you help me please with a problem of Global.asax
implementation? I have little experience.

I have written Global.asax for my ASP.NET application:

<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["Users"] = 0;
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
Application["Users"] = 0;
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Response.Redirect("Error.html");
}
void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["Users"] = (int)Application["Users"] + 1;
Application.Unlock();
}
void Session_End(object sender, EventArgs e)
{
// 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.
Application.Lock();
Application["Users"] = (int)Application["Users"] - 1;
Application.Unlock();
}
</script>

....But it does not work the way I expected because:
Problem 1: Session_End() is not called,
Problem 2: opening my application in a new browser window does not
call Session_Start(), so users counter is not increased.

Here is my Web.Config:
<?xml version="1.0"?>
....
<configuration>
<appSettings/>
....
<system.web>
<compilation debug="true"/>
<authentication mode="Forms">
<forms name="Demo.NET" loginUrl="Default.aspx" />
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<customErrors mode="RemoteOnly" defaultRedirect="Error.html">
</customErrors>
<sessionState mode="InProc"
cookieless="false"
timeout="20"/>
</system.web>
</configuration>

Could you help me to solve problems 1st and 2nd?
Thank you very much!
/RAM/
Apr 8 '06 #1
1 1150
I only have a suggestion for Problem 2. If you already have an
instance of IE open and you pres ctrl+n or "file > new > window" to
create a new window does not start a new session if the default IE
settings are used.

First of all, the only way to start a new session accross multiple IE
windows is by changing a setting and using the task bar IE shortcut
instead of using ctrl+n.

What you have to do is go to Tools > Internet Options > "Advanced" tab
and uncheck the "Reuse windows for launching shortcuts". This will
make sure that everytime you launch a new instance of IE, through the
shortcut in the taskbar or programs menu, that a new IEXPLORER.exe
instance is launched.

If i remember correctly, sessions are only persitant to the instance of
IEXPLORER.exe that it was created on.

Hope that helps.

Jose

Apr 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: John M | last post by:
Hello, On Microsoft Visual Studio .NET 2003, I want to use some global elements, that can be used in each one of my pages. i.e I put a oleDBConnection on global.asax.vb How can I use it...
7
by: Ankit Aneja | last post by:
I put the code for url rewrite in my Application_BeginRequest on global.ascx some .aspx pages are in root ,some in folder named admin and some in folder named user aspx pages which are in user...
10
by: Ronnie | last post by:
I've created a simple web application using VS2005 Beta 2. Basically, I've added a Web Form and a Global.asax file. In my Global.asax, I create a method like: public static void TestGlobal()...
8
by: Thomas Coleman | last post by:
Ok, I've obviously discovered that Global.aspx has been completely changed in ..NET 2.0. However, I haven't figured out how to declare a constant that's available to any page in my application...
11
by: Ron | last post by:
I have a web project compiled with the new "Web Deployment Projects" plugin for VS2005. I'm deploying the web project to one assembly and with updateable option set to ON. When I'm running the...
2
by: rgparkins | last post by:
Hi Guys Maybe a simple and easy solution to this, but I keep getting exception object not set to instance etc etc. I have a Timer that is initiated in Application_Start in Global.asax. This...
4
by: Al Santino | last post by:
Hello, I've created a simple C# web services project using Visual Studio 2005. My service compiles and runs correctly when called by remote clients. I'm able to step through the service in the...
8
by: Victor | last post by:
Can I get the events in GLOBAL.ASAX to fire if a classic ASP page is being accessed by the user?
8
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project...
12
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I am trying to maintain a list of people who are currently "online" in SQL. I do this by adding a simple entry to a simple PeopleOnline table whenever someone logs in to my site. If they...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.