为什么 httpRuntime targetFramework="4.5" 禁用抓取 .ASPXAUTH cookie?

Why does httpRuntime targetFramework="4.5" disable grabbing the .ASPXAUTH cookie?

当我的 web.config 具有以下 httpRuntime 时,我的控制器无法获取 cookie .ASPXAUTH。它似乎能够获取任何其他 cookie,无论是否带有句号前缀。如果我删除下面的行,它工作正常。

<httpRuntime targetFramework="4.5"/>

我正在使用以下方法获取 cookie。

HttpCookie authCookie = Request.Cookies[".ASPXAUTH"];

为什么我无法获取表单身份验证 cookie?

我有类似的问题 - 我的运行时 4.5 的应用程序无法读取由另一个 运行 低于 4.0 的 /login/ 应用程序创建的 .ASPXAUTH cookie,导致重定向循环。原来 4.5 引入了一些密码学改进,可以通过在 web.config 中设置以下内容来启用:

原因:

<machineKey compatibilityMode="Framework45" />

or

<httpRuntime targetFramework="4.5" />

https://blogs.msdn.microsoft.com/webdev/2012/10/23/cryptographic-improvements-in-asp-net-4-5-pt-2/1

解决方案:在我的例子中(许多其他 4.0 应用程序依赖于 cookie)解决方案是切换我的新应用程序以使用:

<machineKey compatibilityMode="Framework20SP1" validationKey="..shared with login app, along with decryptionKey etc...">

or

remove the <httpRuntime /> element

当然这只是一种解决方法,我将尽快将我的所有应用程序更新为更安全的 4.5 身份验证。