3
我正嘗試使用Rotativa組件在Web服務器磁盤上永久存儲(不顯示)發票的副本。兩個問題:如何在磁盤上寫入FileContentResult?
- 爲什麼我需要指定控制器操作? (「索引」,在此 的情況下)
- 如何在不顯示 的情況下在本地磁盤上寫入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?
}