ASP.NET Streaming PDF 字节流 - 如何设置文档标题?
当将 pdf 从 ASP.NET (MVC2) 流式传输到 Chrome 时,我希望能够设置浏览器标题中显示的标题(特别是 Chrome 选项卡标题)。
我生成的响应如下:
HttpContext.Response.Clear();
HttpContext.Response.AppendHeader("title", documentName);
HttpContext.Response.ContentType = contentType;
HttpContext.Response.Cache.SetLastModified(DateTime.Now);
HttpContext.Response.BinaryWrite(docStream);
HttpContext.Response.Flush();
通常,contentType 类似于“application/pdf”。
在 Chrome 中查看时,Chrome 选项卡的标题是文档的完整 URL。我只想将其设置为文档标题。我该怎么做?
When streaming a pdf from ASP.NET (MVC2) to Chrome, I want to be able to set the caption that appears in the browser title (specifically, the Chrome tab caption).
I am generating my response as follows:
HttpContext.Response.Clear();
HttpContext.Response.AppendHeader("title", documentName);
HttpContext.Response.ContentType = contentType;
HttpContext.Response.Cache.SetLastModified(DateTime.Now);
HttpContext.Response.BinaryWrite(docStream);
HttpContext.Response.Flush();
where, typically, contentType is something like "application/pdf".
When viewed in Chrome, the caption of the Chrome tab is the full url of the document. I just want it set to the document title. How do I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 pdf 托管在框架内。这样你就可以设置包含 html 页面的标题。
You could host the pdf inside a frame. This way you can set the title of the containing html page.
您是否尝试过设置文件名?
Have you tried setting a file name?