ASP.Net how to auto start the Application without

2020-04-08 12:47发布

问题:

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?

回答1:

If you are on IIS 7.5, you can setup the application auto start, as you can see on this post on the ScottGu blog.

Basically, you have to add the startMode=”AlwaysRunning” attribute on the application host config file, in the app worker process entry.