gpt4 book ai didi

asp.net-mvc - IE8 和 MVC FileContentResult 的身份验证丢失

转载 作者:行者123 更新时间:2023-12-02 04:07:33 25 4
gpt4 key购买 nike

  • ASP.NET MVC2
  • .NET 3.5
  • 表单例份验证
  • 网址:domain.com/myapp
  • 问题区域:以 FileContentResult
  • 形式返回的动态创建的 PDF

    在 IE8 之前一切正常。在 IE8 中,当用户打开 PDF 然后返回应用程序时,他失去了身份验证。我在表单例份验证 cookie 上添加了一个过期时间,问题似乎得到了解决。但是,我后来发现在父应用程序中也出现了同样的问题。使用持久 cookie,当用户继续使用我的应用程序 (domain.com/myapp) 时,一切都很好,但是当他返回父应用程序 (domain.com) 窗口时,他失去了身份验证。父应用程序使用依赖于 session 状态的专有身份验证和授权架构。

    所以我对这个问题的理解是 FileSystemResult 没有携带任何 session 信息,因此 session 丢失了。我知道,通过向 cookie 添加过期时间,cookie 会被持久化,这使得授权能够在我的应用程序中持久化,即使在打开文档时也是如此。

    我不太明白为什么向我的 cookie 添加过期时间会将问题转移到父应用程序。所以,我错了,这一直在 parent 身上发生。有趣的是,当我连接 Fiddler 观看发生的事情时,问题就消失了。

    您有解决此问题的建议吗?除了将文件写入服务器并返回带有链接以直接打开文件的页面之外,我想不出其他任何东西。

    基于 this question我想我被灌输了。

    最佳答案

    IE8 处理持久性 cookie 的方式发生了一些变化,这可能是您问题的根源。有一个有趣的post这里描述了一个可能的解决方案。

    The solution took us quite a while to find online believe it or not, and when we found it we wanted to kick ourselves for not finding it sooner. It all stems from the domain attribute of the forms authentication settings within the web.config file of your application. We typically left that attribute blank in our apps to make it easier to develop. Further, none of the other browsers above cared about that setting and functioned just fine. However, that changed in IE8 and now that attribute is required.

    关于asp.net-mvc - IE8 和 MVC FileContentResult 的身份验证丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6893330/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com