使用 Chrome 时,响应 Writefile 不会创建 PDF

发布于 2024-12-10 09:53:49 字数 340 浏览 9 评论 0原文

我使用以下代码将 PDF 发送给用户以供打开/下载。这在 IE9 中运行良好。有什么想法为什么它在 Chrome 中不起作用吗?

Response.Clear();

Response.AddHeader("Content-Disposition", "attachment; filename= \"" + myFile + "\"");
Response.AddHeader("Content-Length", myFile.Length.ToString());

Response.WriteFile(myFile.FullName);

Response.Flush();
Response.End();

I'm using the following code to send a PDF to users to open/download. This works fine in IE9. Any ideas why it won't work in Chrome?

Response.Clear();

Response.AddHeader("Content-Disposition", "attachment; filename= \"" + myFile + "\"");
Response.AddHeader("Content-Length", myFile.Length.ToString());

Response.WriteFile(myFile.FullName);

Response.Flush();
Response.End();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

望笑 2024-12-17 09:53:49

添加这个:

Response.ContentType = "application/pdf";

Add this:

Response.ContentType = "application/pdf";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文