473,769 Members | 8,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application_End is not fired when app unloaded. Why?

I am using Application_End to send out a notification about application being
unloaded. I found that those notifications are not being sent because the app
seems to get unloaded without Application_End ever being called. We started
logging Application_Sta rt and Application_End events and found that the
number is not even: Application_Sta rt happen more often than Application_End .
My question is: What are the sutuations in which we should expect
Application_End never being fired when application/process unloaded?
Nov 19 '05 #1
4 9224
1) are you sure the Application is ended?
2) what/how are you logging in the _end?
--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Vlad Hrybok" <Vlad Hr****@discussi ons.microsoft.c om> wrote in message
news:DD******** *************** ***********@mic rosoft.com...
I am using Application_End to send out a notification about application
being
unloaded. I found that those notifications are not being sent because the
app
seems to get unloaded without Application_End ever being called. We
started
logging Application_Sta rt and Application_End events and found that the
number is not even: Application_Sta rt happen more often than
Application_End .
My question is: What are the sutuations in which we should expect
Application_End never being fired when application/process unloaded?

Nov 19 '05 #2
1. Yes. The app has a thread that sends heartbeats to report it's alive. We
noticed that after heartbeats stop coming (application unloaded),
Application_End doesn't always come after that.

2. We log it to Event Viewer.

Thank you,
Vlad Hrybok.

"Curt_C [MVP]" wrote:
1) are you sure the Application is ended?
2) what/how are you logging in the _end?
--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Vlad Hrybok" <Vlad Hr****@discussi ons.microsoft.c om> wrote in message
news:DD******** *************** ***********@mic rosoft.com...
I am using Application_End to send out a notification about application
being
unloaded. I found that those notifications are not being sent because the
app
seems to get unloaded without Application_End ever being called. We
started
logging Application_Sta rt and Application_End events and found that the
number is not even: Application_Sta rt happen more often than
Application_End .
My question is: What are the sutuations in which we should expect
Application_End never being fired when application/process unloaded?


Nov 19 '05 #3
Hi, Vlad.

Are you running on IIS5 or IIS6 ?

If you're running on IIS 5.x, the ASP.NET service runs
under the ASPNET account, and that account has to be
granted privileges in order to write to the Event log.

If you're running on IIS 6, the ASP.NET service runs
under the NETWORK SERVICE account, and that
account has to be granted privileges in order to write
to the Event log.

Does your logging work OK when the Application_End
event does occur ? Or does the logging never happen ?

I did a little test, running on IIS 6, to check out if
Application_OnE nd firs when the Application is
forced to end ( and restart ).

Here's something I wrote which works every time
Application_OnE nd fires ( note: *not* Application_End ):

First, grant the appropiate account
(ASPNET or NETWORK SERVICE) write permission
on any directory you'd like a text file to be written to,
depending on whether you're running IIS5.x or IIS 6.

Then, test this global.asax, which only has a WriteFile
function in the Application_OnE nd event :

global.asax:
------------
<%@ Application Language="C#"%>
<script runat="server">

protected void Application_OnE nd(Object sender, EventArgs e)
{
WriteFile("Appl ication Ended ");
}
void WriteFile(strin g strText)
{
System.IO.Strea mWriter writer = new System.IO.Strea mWriter(@"c:\te st.txt",true);
string str;
str = strText + " " + DateTime.Now.To String( );
writer.WriteLin e(str);
writer.Close( );
}
</script>
---------------

Now, open any *.aspx file in the Application, and then open the
global.asax file in notepad and hit enter to move the text in it
one line down and again back up one line, and save the file.

Editing global.asax will force Application_OnE nd to fire.

You should wind up with a text file in whatever directory
you designated in global.asax, with text similar to this :

------------------------------------------------------------
Application Ended 1/11/2005 2:23:51 AM
------------------------------------------------------------

It should work the same for your Event Logging.

If it doesn't, since this does, you could setup a
FileSystemWatch er Console app to do the logging
for you when changes are made to the text file.

See
http://msdn.microsoft.com/library/de...ClassTopic.asp
for sample code to do that.

Just substitute your logging code for this line:
Console::WriteL ine(S"File: {0} {1}", e->FullPath, __box(e->ChangeType)) ;

Try it out, and let us know how you do.


Juan T. Llibre
ASP.NET MVP
===========
"Vlad Hrybok" <Vlad Hr****@discussi ons.microsoft.c om> wrote in message
news:73******** *************** ***********@mic rosoft.com...
1. Yes. The app has a thread that sends heartbeats to report it's alive.
We
noticed that after heartbeats stop coming (application unloaded),
Application_End doesn't always come after that.

2. We log it to Event Viewer.

Thank you,
Vlad Hrybok.


Nov 19 '05 #4
Juan,
It's IIS 6 on Windows 2003 Server, but logging to the event log is not an
issue - we log just fine. (BTW, to write to the event log you don't have to
grant NETWORK SERVICE any privileges - as long as event source alredy exists
you can write into it from under NETWORK SERVICE just fine, and we create the
event source during the app installation. But it's besides the point.) The
problem is that Application_End doesn't seem to be called sometimes. I need
to determine when it's not being called. When I'm debugging the app and do
standard things that restart the app, like touching web.config or recycling
the app pool - I see application_end called fine. But there is a scenario
where you can see Start events logged and End not. It happens only when
debugging, but I wonder if something like this can happen during normal app
lifecycle?
To reproduce:
1. Build an app that logs Application_Sta rt and Application_End events.
2. Run it by selecting Debug | Start from the menu so that browser opens up.
Observe Application_Sta rt event logged.
3. Close the browser so that debug session ends.
4. Do Build | Rebuild from the menu.
5. Run the app again by selecting Debug | Start from the menu. Observe
Application_Sta rt being logged w/o Application_End being logged.

Note: If you run the same scenarion one more time with one change: run the
app without the debugger, you will see Application_End being logged. The
purpose of the demo was to show that there can be situations when
Application_End not being called. Our problem in production is most likely
something else. Any idea what it could be?

Regards,
Vlad.

Nov 19 '05 #5

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

Similar topics

11
4588
by: Alistair Saldanha | last post by:
I'm looking for the event that is fired by Internet Explorer to an "alert": <SCRIPT> Alert("You already have a session open") </SCRIPT> The event would be webBrowser.Document.???? Much appreciate any help you can give me. Thanks,
4
6901
by: Matt Sawyer | last post by:
I am attempting to use an API (CxApiOem.dll) that has a large number of defines and complicated structs. It's just too much hassle to attempt to use DLLImport to make the desired API calls. Instead, I created a managed C++ DLL (OneBoxAPI.dll) that wraps the desired API calls in a manner which is easy to call from C#. This way I can use the header files that are part of the API for all the defines and structs. I am having a problem...
2
7704
by: Craig | last post by:
Hi, I'm having difficulty understanding how the Application_End event in the Global.asax file gets called. I thought that it's called when the specific web site is stopped via the IIS management console. Could anyone please tell me where I can dispose of objects when wanting to stop a specific web site without having to explicitly run IISRESET, as I have other web sites that I am not allowed to reset on the same machine and calling...
3
16127
by: Jim Owen | last post by:
My .Net book states that the Application_End event handler in Global.asax gets called typically about 20 minutes after the last HTTP request. My question is: what is the best way to debug my Application_End code? I could of course add a button or something to a form to run the code explicitly, but I want to be sure it is really getting called after 20 minutes. I assume that if I put a breakpoint in my Application_End code, and then run the...
4
7085
by: Halcyon Woodward | last post by:
I have an odd problem... We have a small development team (three coders) working on the same project (a C# web application). Each coder has a unique 'sandbox' site on a shared Windows 2003 where they can test the code they write. The majority of the code is written into a stand-alone class library shared via VSS, that is then referenced by each sandbox web (each of which is unique to each user). In the stand-alone class library, we...
4
3050
by: J-T | last post by:
I have my applciation installed in an appplication pool (a worker process) -IIS 6.0-which is defined to be shut down after 20 minutes of being idle.If I put a breakpoint in Application_End method of Global.asax and there is no request for 20 minutes ,dose the breakpoint works for me? Is there a document which can gives me more infomration in this behaviour? Thanks
1
1369
by: an | last post by:
I've implemented a call-back function to repopulate the stored Cache objects when they expires or are removed it works great but in one situation only it doesen't work (that is the callback is not fired): when,
4
365
by: =?Utf-8?B?c2Vhbl9tY2Fk?= | last post by:
I have now confirmed that my application level objects are being killed during worker process “recycle”. I was going to write some code to re-create these objects at the Application_Start event however that event doesn’t fire until the next request to the web site. The trouble here is that I need those applications alive regardless of visits because they contain email timers. It’s fine to lose it them for a few minutes but all...
5
5199
by: Tenacious | last post by:
I am trying to shutdown a database server in the Application_End event handler on the Global.asax page. So far I am trying this only on the development server that comes with Visual Studio 2005. When I close the browser, this does not cause the Application_End event to trigger. It also will not occur when I shut down the development server. At this point the application is no longer running, so why didn't the event handler ever get called?...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.