asp.net-web-api

How Web API application start event get fired?


I have made a REST web API and I thought the application_start() event of a web API should triggered once you start the web service from IIS manager. However, what I have observed to my web API is it only triggered by the first web request which reached to the web service. I was wondering if this is supposed to be or I did it incorrectly? Thanks.


Solution

  • That's how it is. From the docs:

    Called when the first resource (such as a page) in an ASP.NET application is requested. TheĀ Application_Startmethod 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.

    https://msdn.microsoft.com/en-us/library/ms178473.aspx