【问题标题】:Why does httpRuntime targetFramework="4.5" disable grabbing the .ASPXAUTH cookie?为什么 httpRuntime targetFramework="4.5" 禁用抓取 .ASPXAUTH cookie?
【发布时间】:2015-12-12 06:01:41
【问题描述】:

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

<httpRuntime targetFramework="4.5"/>

我正在使用以下内容来获取 cookie。

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

为什么我不能获取表单身份验证 cookie?

【问题讨论】:

  • web.config 中有&lt;authentication mode="Forms"&gt; 标签吗?如果 targetFramework="4.5",您是否在客户端浏览器中看到名为 .ASPXAUTH 的 cookie?
  • 我在 web.config 中有身份验证模式="Forms">。这是一个 RESTish 服务,所以我没有在浏览器中尝试过任何东西。我知道如果我使用 curl 发送带有 cookie 的请求,控制器将无法获取该 cookie。

标签: c# asp.net-mvc cookies asp.net-membership forms-authentication


【解决方案1】:

我有类似的问题 - 我的运行时 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 身份验证。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-30
    • 2016-08-11
    • 1970-01-01
    • 2013-09-16
    • 1970-01-01
    • 2010-11-22
    • 2018-10-24
    • 1970-01-01
    相关资源
    最近更新 更多