更新时间:2023-11-23 10:30:46
您不能强制文件下载到的地方。
You can't force the place the file is downloaded to.
在您的code,你不应该写入文件,但对 的OutputStream
从响应。
In your code, you shouldn't write to file, but to the OutputStream
from the response.
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=\"file.pdf\"");
HttpContext.Current.Response.OutputStream.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);