2014-12-18 3 views
0

웹 서비스를 호출하여 바우처를 받고 웹 서비스가 KO 인 경우 때때로 오류가 발생합니다. 다른 작업으로 리디렉션해야합니다. 액션 : 다음과 같은 일을해야합니다.FileResult + redirectToAction on ERROR

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"); 
     } 

    } 

어떻게하면됩니까?

+0

는 작동하지 않습니다? –

+0

retuen을 Action 결과로 변경하면 파일을받지 못합니다. – user1428798

+0

정말 이상합니다. –

답변

0

이 시도 : 당신이 ActionResult로 반환 유형을 지정하는 경우

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