Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net how to auto start the Application without user first request to the server?

I have some scheduled jobs that need to be run in the Application_Start but as far as I know, this method only get triggered after the first request. Is there anyway I can just auto startup the application after I stop and start the connection in IIS or stop/start/restart the site?

like image 223
Leo Avatar asked Nov 14 '22 05:11

Leo


1 Answers

I. Install the Application Initialization Module The application initialization module allows IIS to preemptively perform initialization tasks such as making the initial HTTP request to your application, or call your custom logic to perform whatever you desire to warm up your app. I find it necessary to install the module even though the settings for making an application auto start and always running are there on IIS 10 which is the server I am using. You can install the Application Initialization module via the Server Manager.

You can find the module under Server Roles -> Web Server -> Application Developer -> Application Initialization.

II. Configure the app pool In IIS Manager, right click on the application pool under which the application runs and select “Advanced Settings”. Update the following values: • Set the .NET CLR version to v4.0. • Set start mode to “Always Running”. • Set Idle Time-Out (minutes) to 0.

III. Configure the IIS site In IIS Manager, right click on the site for the application, select “Manage Website” -> “Advanced Settings” and set the “Preload Enabled” value to true.

like image 67
Chaitanya Bhure Avatar answered Dec 23 '22 08:12

Chaitanya Bhure