Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I have some code within the Application_Start event in Global.asax
that runs a sqlscript against sql server to check the fetch some data
for mail sending in time interval. My problem is that sometimes the
Application_Start event doesn't fire, it skips it and goes directly to my default.aspx file.

I do the following:

1. IIS Reset.
2. Deploy application files.
3. Start http://localhost/default.aspx

Sometimes the Application_Start is fired, other times it doesn't. I
have seen that this more often do happen in my production environment
(IIS 6.0, Windows Server 2003) than on my developer machine.

Is that any clue
Posted
Updated 8-Apr-11 2:46am
v2

Application_Start event is fired only at the time of first time call to any page in Web-Application.
Once this event is called, it will not be called till the time either virtual directory's structure drastically changed or your production server is Stopped/Restarted.
Mostly production servers are not updated frequently and not even Restarted or Stopped.
Although to get Application_Start event to get fired, you have to Stop and Restart the IDE created localhost or the IIS server itself.
 
Share this answer
 
Hmmm... I am sure I saw this exact post yesterday (i.e. well before you posted this) - are you posting this on another forum too?

Anyway, I spotted it as I was looking for a reason too. Mine however, involved running it from VS 2010 in the development server. There are some rules to make the event fire...

1. You must 'stop' the development server which each run - right click the icon in the tray to do this (Enabling 'Edit and Continue' in the project properties -> web tab may auto force a restart)

2. Ensure the project is marked as the start-up project if you have multiple projects in the solution (right-click the project to do this)

As you are deploying to IIS, I can only assume a site restart will cause it to happen. But keep in mind the event will fire when the website is started - NOT when you navigate to it (for this you may want to look at the Session_Start event instead, perhaps)

Also, you should really "Deploy application files" before you "IIS Reset"
 
Share this answer
 
v2
My Friend,

Application_Start Event fires only one time..
It fires when u reset the iis or edit web.config file..
it is not gonna fire more then one time..

move your code from that event..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900