写PDF流响应流 [英] Write PDF stream to response stream

查看:88
本文介绍了写PDF流响应流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个PDF文件作为一个流,我怎么能写的响应输出流?

If I have a pdf file as a Stream, how can I write it to the response output stream?

推荐答案

由于您使用的MVC,最好的方法是使用 FileStreamResult

Since you are using MVC, the best way is to use FileStreamResult:

return new FileStreamResult(stream, "application/pdf")
{
    FileDownloadName = "file.pdf"
};

的Response.Write 播放或 Response.OutputStream 从你的控制器不地道,而且也没有理由当一个已经存在编写自己的ActionResult。

Playing with Response.Write or Response.OutputStream from your controller is non-idiomatic and there's no reason to write your own ActionResult when one already exists.

这篇关于写PDF流响应流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆