编程语言
首页 > 编程语言> > c# – 为什么httpRuntime targetFramework =“4.5”禁用抓取.ASPXAUTH cookie?

c# – 为什么httpRuntime targetFramework =“4.5”禁用抓取.ASPXAUTH cookie?

作者:互联网

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

<httpRuntime targetFramework="4.5"/>

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

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

为什么我不能获取Forms Authentication cookie?

解决方法:

我有类似的问题 – 我的应用程序与运行时4.5无法读取由4.0下运行的另一个/ login / app创建的.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身份验证.

标签:c,asp-net-mvc,cookies,forms-authentication,asp-net-membership
来源: https://codeday.me/bug/20190628/1315082.html