asp.net - 某些 pdf 文件未在 chrome 中完全加载
问题描述
我在网站上有大约 100 个 pdf 文件,在昨天之前它们都运行良好。
从昨天开始,一些文件将无法完全加载,只有第一页会以 chrome 显示。
有几点需要注意:
- 所有 pdf 在除 chrome 之外的所有浏览器中仍然可以正常工作。
- 我将所有文件和数据库复制到临时站点,所有 pdf 在包括 chrome 在内的所有浏览器中都可以正常工作。登台站点位于同一台服务器上。
- 有时未加载的文件会加载,但随后会再次损坏。我无法确定它发生的原因。
- 没有创建/显示 pdf 的代码,打开 pdf 的链接仅指向服务器上的实际 pdf 位置。
- 当 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,但它并没有解决问题。
任何帮助,将不胜感激。
解决方案
我无法弄清楚这个问题,但是在我更改代码以使用 Asp.Net 打开 pdf 后,问题得到了解决。
这是我添加的代码示例:
Response.Clear();
string filePath = "/downloads/" + Request.QueryString["file"];
Response.ContentType = "application/pdf";
Response.WriteFile(filePath);
Response.End();
推荐阅读
- python - BeautifulSoup get_text 结果作为字符串变量?
- python - 会话不是持久的,即使在 Flask 中设置了密钥
- c - realloc,二维分配,valgrind中的泄漏和错误
- django - 与 Django 频道的语音聊天集成
- reactjs - 设置 React 和运行 npm run dev 时遇到问题
- python - 如何从文本文件中找到拆分浮动列表的平均值?
- html - 所选选项的打字稿结果
- android - 我需要找到一种方法来缩放我的网格以适应 Flutter 中设备的正确屏幕尺寸
- r - 如何将数据拟合到 Clayton copula 并在 R 中找到 KS GOF 测试的 p 值?
- ruby-on-rails - Heroku:LoadError:无法加载此类文件——mimemagic/overlay