ASP.Net MVC3Webアプリケーションを開発しています。WebサイトをSSL証明書で保護する必要がありますが、これは、アプリケーションがテストサーバーではなく、ライブサーバー上にある場合にのみ使用します。
したがって、WebConfigでAppSettingを次のように設定します。
<appSettings>
<add key="SSL" value="false" />
</appSettings>
次に、アカウントコントローラーでこの値(TrueまたはFalse)を取得し、その値を使用して、LogOnアクションにRequiresHttps属性を設定するかどうかを決定します。そういうことをしたい
public class AccountController : Controller
{
public string SSL = System.Configuration.ConfigurationManager.AppSettings["SSL"];
if (SSL.Equals("true"))
{
[RequireHttps]
}
public ActionResult LogOn()
{
return View();
}
}
しかし、IFステートメントを現在の場所に置くことはできませんが、私が何を達成しようとしているのかを理解していただければ幸いです。
私のアイデアをどのように実装できるかについて誰かが何か提案がありますか?
ありがとう。