Initialize some variable when first user accesses application - ASP.NET Introduction

Q.  You need to initialize some variable only when the first user accesses the application. What should you do?
- Published on 19 Oct 15

a. Add code to the Application_OnStart event handler in the Global.asax file.
b. Add code to the Application_BeginRequest event handler in the Global.asax
c. Add code to the Session_OnStart event handler in the Global.asax file
d. None of the above

ANSWER: Add code to the Application_OnStart event handler in the Global.asax file.
 
Application_Start event runs only ones when the application started. It is used to serve application - level and session - level events.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)