Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there some initialization area in ASP.NET that only runs once?

Tags:

asp.net

I've got a piece of code that I want to run one time when my website is first loaded. It is basically a static initialization of another module.

Is there some event I can hook into that runs when the site is first served to a client? It doesn't even need to be per session, just on first load to any client.

I'm using vs2010, .net 4.0, asp.net 4.0

like image 323
Erix Avatar asked Dec 17 '22 19:12

Erix


1 Answers

You can use the Application_Start event.

See MSDN ASP.NET Application Life Cycle Overview

Application_Start is 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.

like image 177
CD.. Avatar answered Apr 06 '23 00:04

CD..