更新时间:2023-02-14 19:49:52
更新: FilePathResult
使用的 response.TransmitFile 其中直接写入指定的文件到一个HTTP响应输出流,无需在内存中缓存它。 这里的源$ C $ C为MVC 。
UPDATE: FilePathResult
uses response.TransmitFile which "Writes the specified file directly to an HTTP response output stream, without buffering it in memory.". Here's the source code for MVC.
您可以使用 FileStreamResult
类流数据传回:
You can stream data back using the FileStreamResult
class:
return new FileStreamResult(stream, "application/pdf")
{
result.FileDownloadName = "somefile.pdf";
};
或者你可以重定向到像这样的文件:
Or you could redirect to the file like this:
return Redirect("somefile.pdf");