PC Review


Reply
Thread Tools Rate Thread

Applicaation_Start doesn't always fire ?

 
 
Patrice
Guest
Posts: n/a
 
      26th Jan 2007
Hi all,

Got a strange problem.

In Application_Start, I just store the current date/time in an application
variable to keep track of the last time the application started.

To my surprise, I noticed in my error reporting log (that dumps various
things including this application variable) that sometimes this application
variable is not set.

I then added in beginrequest some code to fill the same application variable
all along with the event that set it (if not already set).

For now it looks like :
- if I update the web application (dll, web.config etc...) the global
variable shows the correct date/time set in application_start
- then the next day, the application variable generally shows today's date
and was set from beginrequest earlier in the day.

It occurs even when pages were accessed less than 20 minutes earlier the
alleged restart.

For now it would seem to me that when the application pool is
stopped/restarted by IIS or something similar, the application looses its
application variables. The variable is then set in the begin_request event.

It doesn't cause any problem as I have nothing special in this event but I
really like to undestansd what is happening...
Thanks in advance.

--

Patrice




 
Reply With Quote
 
 
 
 
Thomas Hansen
Guest
Posts: n/a
 
      26th Jan 2007


On Jan 26, 11:53 am, "Patrice" <http://www.chez.com/scribe/> wrote:
> Hi all,
>
> Got a strange problem.


It isn't very strange, in fact Application_Start only fires _when the
application starts_
Normally after an Application_End...

This doesn't nessecary happen every "n'th hour" or when you press F5 in
de debugger etc...
Under perfect circumstances the Application_Start will be called ONCE
and then NEVER again until END OF TIME...!!


..t

--
http://ajaxwidgets.com
Free ASP.NET Ajax Widgets NOW!

 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      26th Jan 2007
Yes, but it looks like at some point I loose the application variable that
is defined in Application_Start. Then as, it doesn't exist any more it is
set in BeginRequest.

I assumed this was because the application stopped (loosing application
variables) and was restarted without application_start being fired (which
would have populate again the variable). As the application variable is not
populated yet then beginrequest populate it... This is the behavior I see.

That said you made me think that it could be something else. The application
perhaps doesn't restart at all but for some reason, I loose the application
variable. I'll try to see if something could cause this...

---
Patrice


"Thomas Hansen" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed)...
>
>
> On Jan 26, 11:53 am, "Patrice" <http://www.chez.com/scribe/> wrote:
>> Hi all,
>>
>> Got a strange problem.

>
> It isn't very strange, in fact Application_Start only fires _when the
> application starts_
> Normally after an Application_End...
>
> This doesn't nessecary happen every "n'th hour" or when you press F5 in
> de debugger etc...
> Under perfect circumstances the Application_Start will be called ONCE
> and then NEVER again until END OF TIME...!!
>
>
> .t
>
> --
> http://ajaxwidgets.com
> Free ASP.NET Ajax Widgets NOW!
>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      26th Jan 2007
I saw in a past error report that I have a session start (I also track this
one) that is earlier than the time at which the application variable has
been populated again.

So it definitely looks like the problem is not that the application restarts
but that it looses this application variable for some other reason. I'll try
to see if I have some code that could cause this...

Back on a new track... Thanks.


"Patrice" <http://www.chez.com/scribe/> a écrit dans le message de news:
u%(E-Mail Removed)...
> Yes, but it looks like at some point I loose the application variable that
> is defined in Application_Start. Then as, it doesn't exist any more it is
> set in BeginRequest.
>
> I assumed this was because the application stopped (loosing application
> variables) and was restarted without application_start being fired (which
> would have populate again the variable). As the application variable is
> not populated yet then beginrequest populate it... This is the behavior I
> see.
>
> That said you made me think that it could be something else. The
> application perhaps doesn't restart at all but for some reason, I loose
> the application variable. I'll try to see if something could cause this...
>
> ---
> Patrice
>
>
> "Thomas Hansen" <(E-Mail Removed)> a écrit dans le message de news:
> (E-Mail Removed)...
>>
>>
>> On Jan 26, 11:53 am, "Patrice" <http://www.chez.com/scribe/> wrote:
>>> Hi all,
>>>
>>> Got a strange problem.

>>
>> It isn't very strange, in fact Application_Start only fires _when the
>> application starts_
>> Normally after an Application_End...
>>
>> This doesn't nessecary happen every "n'th hour" or when you press F5 in
>> de debugger etc...
>> Under perfect circumstances the Application_Start will be called ONCE
>> and then NEVER again until END OF TIME...!!
>>
>>
>> .t
>>
>> --
>> http://ajaxwidgets.com
>> Free ASP.NET Ajax Widgets NOW!
>>

>
>



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      26th Jan 2007
re;
>I saw in a past error report that I have a session start (I also track this one) that is earlier
>than the time at which the application variable has been populated again.


That's impossible.

Application_Start fires earlier that Session_Start.
It's the first event for all ASP.NET Applications and must fire before any other events fire.

See:
http://msdn2.microsoft.com/en-us/library/ms178473.aspx

re:
> So it definitely looks like the problem is not that the application restarts but that it loses
> this application variable for some other reason.


That is highly unlikely.

Are you using Application.Lock when you set the application variable ?




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:%(E-Mail Removed)...
>I saw in a past error report that I have a session start (I also track this one) that is earlier
>than the time at which the application variable has been populated again.


> So it definitely looks like the problem is not that the application restarts but that it looses
> this application variable for some other reason. I'll try to see if I have some code that could
> cause this...
>
> Back on a new track... Thanks.



> "Patrice" <http://www.chez.com/scribe/> a écrit dans le message de news:
> u%(E-Mail Removed)...
>> Yes, but it looks like at some point I loose the application variable that is defined in
>> Application_Start. Then as, it doesn't exist any more it is set in BeginRequest.
>>
>> I assumed this was because the application stopped (loosing application variables) and was
>> restarted without application_start being fired (which would have populate again the variable).
>> As the application variable is not populated yet then beginrequest populate it... This is the
>> behavior I see.
>>
>> That said you made me think that it could be something else. The application perhaps doesn't
>> restart at all but for some reason, I loose the application variable. I'll try to see if
>> something could cause this...
>>
>> ---
>> Patrice
>>
>>
>> "Thomas Hansen" <(E-Mail Removed)> a écrit dans le message de news:
>> (E-Mail Removed)...
>>>
>>>
>>> On Jan 26, 11:53 am, "Patrice" <http://www.chez.com/scribe/> wrote:
>>>> Hi all,
>>>>
>>>> Got a strange problem.
>>>
>>> It isn't very strange, in fact Application_Start only fires _when the
>>> application starts_


>>> Normally after an Application_End...
>>>
>>> This doesn't nessecary happen every "n'th hour" or when you press F5 in
>>> de debugger etc...
>>> Under perfect circumstances the Application_Start will be called ONCE
>>> and then NEVER again until END OF TIME...!!



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      26th Jan 2007
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:%(E-Mail Removed)...

>I saw in a past error report that I have a session start (I also track this
>one) that is earlier than the time at which the application variable has
>been populated again.


That simply can't happen...


 
Reply With Quote
 
Arundhati Anavekar
Guest
Posts: n/a
 
      26th Jan 2007
try to track the sequecne of enevts by injecting Print-to-file
statements in global.asax it should return:

Application_Start
Application_BeginRequest
Application_AuthenticateRequest
Session_Start
Application_EndRequest
Application_BeginRequest
Application_AuthenticateRequest
Application_EndRequest
Application_BeginRequest
Application_AuthenticateRequest
Application_EndRequest
Session_End
Application_End

but you will notice that even after to close the application, the file
is not created immediately but after sometime, this is because IIS does
not immediately release the application space thus Application_End is
not instantly called. your guess that "application pool is
stopped/restarted by IIS or something similar," or some reason the
variable value is getting lost and gained without a proper path. I
understand my writing may not make much help but tracking the flow
could help reach a solution.

 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      26th Jan 2007
I was thinking more to something like having Application.Clear somewhere.
That would clear the application variable but would left session variables
unchanged.

Let's rephrase the problem wihtout any assumption from my part.

The Application_Start event stores a " _Start" applciation variable that has
the current date/time of the event (not using lock).

The only usage of this application variable is to be dumped in error
reports. It is only read, never written once stored...

I see this variable in some other reports but starting at some point, this
variable is no more available in error reports...

---
Patrice


"Juan T. Llibre" <(E-Mail Removed)> a écrit dans le message de
news: %(E-Mail Removed)...
> re;
>>I saw in a past error report that I have a session start (I also track
>>this one) that is earlier than the time at which the application variable
>>has been populated again.

>
> That's impossible.
>
> Application_Start fires earlier that Session_Start.
> It's the first event for all ASP.NET Applications and must fire before any
> other events fire.
>
> See:
> http://msdn2.microsoft.com/en-us/library/ms178473.aspx
>
> re:
>> So it definitely looks like the problem is not that the application
>> restarts but that it loses this application variable for some other
>> reason.

>
> That is highly unlikely.
>
> Are you using Application.Lock when you set the application variable ?
>
>
>
>
> Juan T. Llibre, asp.net MVP
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ===================================
> "Patrice" <http://www.chez.com/scribe/> wrote in message
> news:%(E-Mail Removed)...
>>I saw in a past error report that I have a session start (I also track
>>this one) that is earlier than the time at which the application variable
>>has been populated again.

>
>> So it definitely looks like the problem is not that the application
>> restarts but that it looses this application variable for some other
>> reason. I'll try to see if I have some code that could cause this...
>>
>> Back on a new track... Thanks.

>
>
>> "Patrice" <http://www.chez.com/scribe/> a écrit dans le message de news:
>> u%(E-Mail Removed)...
>>> Yes, but it looks like at some point I loose the application variable
>>> that is defined in Application_Start. Then as, it doesn't exist any more
>>> it is set in BeginRequest.
>>>
>>> I assumed this was because the application stopped (loosing application
>>> variables) and was restarted without application_start being fired
>>> (which would have populate again the variable). As the application
>>> variable is not populated yet then beginrequest populate it... This is
>>> the behavior I see.
>>>
>>> That said you made me think that it could be something else. The
>>> application perhaps doesn't restart at all but for some reason, I loose
>>> the application variable. I'll try to see if something could cause
>>> this...
>>>
>>> ---
>>> Patrice
>>>
>>>
>>> "Thomas Hansen" <(E-Mail Removed)> a écrit dans le message de news:
>>> (E-Mail Removed)...
>>>>
>>>>
>>>> On Jan 26, 11:53 am, "Patrice" <http://www.chez.com/scribe/> wrote:
>>>>> Hi all,
>>>>>
>>>>> Got a strange problem.
>>>>
>>>> It isn't very strange, in fact Application_Start only fires _when the
>>>> application starts_

>
>>>> Normally after an Application_End...
>>>>
>>>> This doesn't nessecary happen every "n'th hour" or when you press F5 in
>>>> de debugger etc...
>>>> Under perfect circumstances the Application_Start will be called ONCE
>>>> and then NEVER again until END OF TIME...!!

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event doesn't fire =?Utf-8?B?RnJhbmsgWGlh?= Microsoft Excel Misc 6 11th Feb 2006 12:54 AM
Form1_KeyDown doesn't fire genc ymeri Microsoft C# .NET 4 8th Apr 2004 07:13 PM
Event doesn't fire Alberto Microsoft ASP .NET 1 4th Mar 2004 03:08 AM
AT command doesn't fire Peter Windows XP Basics 0 16th Oct 2003 08:13 PM
COM events doesn't fire Frank Matheis Microsoft VB .NET 2 9th Jul 2003 11:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:41 AM.