gpt4 book ai didi

c# - FileResult + redirectToAction出现错误

转载 作者:行者123 更新时间:2023-12-03 08:55:22 26 4
gpt4 key购买 nike

有时我在调用Web服务以获取凭证且Web服务为KO时出现错误。我需要重定向到其他操作:我需要执行以下操作:

  public virtual FileResult Ticket(int operationCategoryId, int orderId)
{
try
{
var orderDetail = _orderDetailBusiness.GetOrderDetail(operationCategoryId, orderId);
byte[] ticketContent = _vpTicketMinuteBusiness.GetTicketContent(orderDetail.Parcels);
return File(ticketContent, "application/pdf", orderId + ".pdf");
}
catch (NullReferenceException exception)
{
return RedirectToAction("Error");
}

}

我怎样才能做到这一点?

最佳答案

尝试这个:

 return new FileStreamResult(ms, "application/ms-excel")
{
FileDownloadName = "yourfile.xlsx",
};

关于c# - FileResult + redirectToAction出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27552460/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com