本文可協助您解決應用程式初始化模組無法針對設定為需要安全套接字層 (SSL) 的網站運作的問題。
原始產品版本: ASP.NET
原始 KB 編號: 2843964
徵兆
先前稱為 應用程式熱身 的應用程式初始化模組不適用於設定為需要 SSL 的網站。
原因
這是依照設計的行為。
熱身模組會使用超文本傳輸通訊協定 (HTTP) 傳送要求,而不是使用超文本傳輸通訊協定安全 (HTTPS)。 建議的因應措施會允許來自熱身模組的 HTTP 要求至 localhost,但它會重新導向至其餘要求的 HTTPS,因此在此設計表示熱身模組會透過 HTTP 提出要求。
解決方法
若要解決這項限制,您可以考慮啟用 HTTP(未核取 IIS 管理員>SSL 設定下的 [需要 SSL] 設定),並使用 URL 重寫規則將 HTTP 要求重新導向至 HTTPS,但來自熱身模組的要求除外:
<rewrite>
<rules>
<rule name="No redirect on warmup request (request from localhost with warmup user agent)"
stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="localhost" />
<add input="{HTTP_USER_AGENT}" pattern="Initialization" />
</conditions>
<action type="Rewrite" url="{URL}" />
</rule>
<rule name="HTTP to HTTPS redirect for all requests" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>