HTTPサイトをHTTPSにリダイレクトする必要があります。以下のルールを追加しましたが、http://www.example.comを試してみると403エラーが表示されます。https://www.example.comブラウザ。MVCアプリケーション(IIS7.5)でHTTPSをHTTPSにリダイレクトする方法
Global.asax.cs
protected void Application_BeginRequest(){
if (!Context.Request.IsSecureConnection)
Response.Redirect(Context.Request.Url.ToString().Replace("http:", "https:"));
}
をしたり、アクションフィルタに同じコードを追加することができます::
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
を?どういう意味ですか? –
IISの下にある "URL rewirte"モジュールを使用してルールを追加しました。これはweb.configにあります。 – LLM