【问题标题】:Some pdf files are not loading completely in chrome某些 pdf 文件未在 chrome 中完全加载
【发布时间】:2020-02-28 23:27:39
【问题描述】:

我在网站上有大约 100 个 pdf 文件,在昨天之前它们都运行良好。

从昨天开始,一些文件无法完全加载,只有第一页会以 chrome 显示。

注意事项:

  1. 所有 pdf 在除 chrome 之外的所有浏览器中仍然可以正常工作。
  2. 我将所有文件和数据库复制到暂存站点,所有 pdf 文件在包括 chrome 在内的所有浏览器中都能正常工作。暂存站点位于同一台服务器上。
  3. 有时会加载未加载的文件,但随后会再次损坏。我无法确定发生这种情况的原因。
  4. 没有创建/显示 pdf 的代码,打开 pdf 的链接仅指向服务器上的实际 pdf 位置。
  5. 当 pdf 未加载时,控制台日志中显示的唯一内容是以下警告:

A cookie associated with a cross-site resource at "" was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.

我尝试添加 cookieSameSite="Strict" 和 Lax,但没有解决问题。

任何帮助将不胜感激。

【问题讨论】:

  • 除非你真的在 Chrome 中编写了 PDF 渲染代码(在这种情况下我们希望看到 minimal reproducible example),否则这个问题是关于一般软件(错误)行为的,
  • 嗨,这是软件(错误)行为。我是否必须更改我的问题/标签,还是应该在找到修复程序后将其删除?
  • 你的解决方法是不使用 Chrome :P 一般软件问题继续Super User,在 Stack Overflow 上只有编程问题是主题。

标签: asp.net google-chrome pdf


【解决方案1】:

我无法找出问题所在,但在我更改代码以使用 Asp.Net 打开 pdf 后,问题得到了解决。

这是我添加的代码示例:

Response.Clear();
string filePath = "/downloads/" + Request.QueryString["file"];
Response.ContentType = "application/pdf";
Response.WriteFile(filePath);
Response.End();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-29
    • 2013-01-20
    • 2012-11-03
    • 1970-01-01
    相关资源
    最近更新 更多