【发布时间】:2014-09-17 11:58:19
【问题描述】:
我正在尝试使用Rotativa 组件将发票的副本永久存储(不显示)在网络服务器磁盘上。两个问题:
- 为什么需要指定控制器操作? (“索引”,在此 案例)
- 如何将 FileContentResult 写入本地磁盘而不 显示它?
谢谢。
这是我的代码:
[HttpPost]
public ActionResult ValidationDone(FormCollection formCollection, int orderId, bool fromOrderDetails)
{
Order orderValidated = context.Orders.Single(no => no.orderID == orderId);
CommonUtils.SendInvoiceMail(orderValidated.customerID , orderValidated.orderID);
var filePath = Path.Combine(Server.MapPath("/Temp"), orderValidated.invoiceID + ".pdf");
var pdfResult = new ActionAsPdf("Index", new { name = orderValidated.invoiceID }) { FileName = filePath };
var binary = pdfResult.BuildPdf(ControllerContext);
FileContentResult fcr = File(binary, "application/pdf");
// how do I save 'fcr' on disk?
}
【问题讨论】:
标签: asp.net-mvc pdf pdf-generation