Application_Start() event in global.asax

走远了吗. 提交于 2019-12-04 05:45:55

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.

Application_Start only runs when the first person goes to the site and when the app_pool refreshes.

It does not happen on every hit to the site.

you might want to think of something like http://www.webcron.org/ for a cron-like system to schedule tasks.

It should be on the Application_BeginRequest plus a DB storing the state for every visitor. But the most appropriate is on Scheduler.

For the full picture - here is list of all events which can be fired in global.asax:

http://aspalliance.com/1114_Understanding_the_Globalasax_file.3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!