所以我把它放在我的 Global.asax.cs 中以使用 HSTS 强制执行 HTTPS
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (!Request.IsLocal && AppSettings.IsSSLEnforced)
{
switch (Request.Url.Scheme)
{
case "https":
Response.AddHeader("Strict-Transport-Security", "max-age=300");
break;
case "http":
var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", path);
break;
}
}
}
现在,问题是这种强制是基于我的应用程序中的一个设置,它决定是否强制执行,当它设置为不强制时,它仍然在强制执行。如何让它清除并停止重定向?
我尝试添加一个我把
Response.AddHeader("Strict-Transport-Security", "max-age=0");
将 max-age 设置为 0 不起作用。如何删除它?似乎 max-age 不起作用(我正在使用 chrome),因为它已经超过 300 秒(5 分钟)
编辑:我现在尝试在 IE 中加载,但它不执行重定向,我尝试进入 chrome 设置并删除条目,但仍然没有。