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

标签 asp.net-mvc cookies forms-authentication

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

    相关文章:

    javascript - 在 asp.net mvc 中单击按钮后创建一个文件夹

    ASP.NET "Remember Me"cookie

    php - Yii 用户在 15-30 分钟后退出,尽管 session 超时设置为至少 1 天

    cookies - 使用表单例份验证的照片上传 Phonegap 请求失败

    c# - 如何在表单例份验证中将 User.Identity.IsAuthenticated 的值设置为 false

    c# - 为什么在 Request.Cookies[FormsAuthentication.FormsCookieName] 中找不到 ASPXAUTH cookie?

    c# - JSON.NET DataContractJsonSerializer 和 Newtonsoft JSON 序列化程序有什么区别

    .NET 和瘦 Controller /胖模型概念

    c# - 在 ASP.MVC 中测试具有相同名称的 Controller 中的 GET/POST 方法

    ruby-on-rails - “remember me” 复选框的集成测试失败