ASP.Net MVC5 设置安全和 HTTPOnly 标志

ASP.Net MVC5 set secure and HTTPOnly flags

我需要为我网站的所有 cookie 设置 httponlysecure 标志,以通过我客户的安全扫描。 我认为 web.config 配置正确

<system.web>
   <httpCookies httpOnlyCookies="true" requireSSL="true" lockItem="true" />

它适用于我在我的应用程序中创建的所有 cookie,但不适用于 google analitycs(我知道我对此无能为力)我想是 asp.net(ai_userai_session)。

搜索这两个 cookie 没有结果。 我如何强制使用 httponlysecure 标志?

不知道有没有关系,我也有这个重写规则

<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>

我试图禁用它,但没有任何改变

要求 SSL 的正确方法是通过全局过滤器

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
     filters.Add(new HandleErrorAttribute());
     filters.Add(new System.Web.Mvc.AuthorizeAttribute());
     filters.Add(new System.Web.Mvc.RequireHttpsAttribute());
}

我现在在我的项目中偶然发现了 "ai_session" 和 "ai_user" cookie,我认为它们来自应用程序洞察力。如果您进一步调查,请向社区报告。