0
兩個部分的一個問題,在HTTP重定向到https贊成&重定向所有HTTP到HTTPS
的利弊我們剛剛實施了Azure的網站使用SSL。一些網頁都從http到在Page_Load中HTTPS重定向,使用:
if (!Request.IsLocal && !Request.IsSecureConnection) {
string redirectUrl = Request.Url.ToString().Replace("http:", "https:");
Response.Redirect(redirectUrl, false);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
第一部分 - 沒有任何缺點重定向所有頁面訪問https?
第二部分 - 如果不是,則是上面的代碼做到這一點的最好辦法,還是應該使用URL重寫這樣的:
<rule name="Redirect to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
</rule>
所有的建議表示歡迎。
問候
投下的人可以讓我知道爲什麼嗎?我想提高我對SO的使用。 – OzDave