環境
- Windows Server 2022
- IIS 10
設定
1. IIS Application Pools
- Application Pools, 選擇站台應用程式,右鍵 Advance Settings
- General > Start Mode > AlwaysRunning default OnDemand
- Process Model > Idle Time-out > 0 default 20
- Recycling > Regular Time Interval > 0 default 1740
2. IIS Site
- Sites > Admin ( Your Site ) > 最右邊 Manager WebSIte > Advanced Settings…
- General > Preload Enable > true
3. 安裝 Application Initialization 服務
目的在於站台重啟後,自動啟動ASP.NET應用程式
Windows 2022 有兩種方式新增 Feature
第一種
- Star > Control Panel > Programs and Features
- 選擇左邊 Turn Windows features on or off
第二種
- Star > Server Manager
- 右上角 Manage > Add Roles and Features
安裝 Feature 步驟
- Step 1. Role-base or feature-base installation
- Step 2. Select a server from the server pool
- Step 3. Roles > Web Server (IIS) > Web Server > Application Development > Application Initialization
設定Web.Config
在應用程式重啟後會自動觸發 “/” 的請求
|
|
參考
web.config 設定參考,但是裡面的 Feature 安裝路徑不適用 Windows Server 2022
Feature 安裝路經參考
https://blog.darkthread.net/blog/hangfire-recurringjob-notes/
https://www.nopcommerce.com/en/boards/topic/52046/application-shutdown-many-times-a-day