Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application_Start() event in global.asax

Hai guys, My website has thousands of users... I have implemented a background task of sending mails to every user once a day ... I followed this link to do this...

http://www.codeproject.com/KB/aspnet/ASPNETService.aspx

My question is will Application_Start() will be fired for every user hitting my website... If so every user will be receiving a n number of mails daily so i want to avoid it...

like image 654
ACP Avatar asked Nov 25 '09 02:11

ACP


People also ask

What is Application_Start in global ASAX?

Application_Start. The Application_Start event is fired the first time when an application starts. Session_Start. The Session_Start event is fired the first time when a user's session is started. This typically contains for session initialization logic code.

What is Application_Start?

Called when the first resource (such as a page) in an ASP.NET application is requested. The Application_Start method is called only one time during the life cycle of an application. You can use this method to perform startup tasks such as loading data into the cache and initializing static values.

In which of the following Application_Start event is available?

Application_Start event is available in which file? Application_Start event is available in Global. asax file.


1 Answers

The Application_Start and Application_End methods are special methods that do not represent HttpApplication events. ASP.NET calls them once for the lifetime of the application domain, not for each HttpApplication instance.

So When first user will open the site it will hit the application_start method after that it will not.

I will add that what you are trying to do is risky. If you want to do batch email sending then you may want to think about Scheduler which can send emails daily.

like image 188
Zeus Avatar answered Oct 15 '22 01:10

Zeus