2014-09-22 1 views
0

저는 MVC ASP.NET 웹 사이트에서 FedEx 배송을 통합해야합니다. 배송 과정에서 생성되는 프로세스가 끝나면 PDF를 열어야합니다. 하지만 웹 사이트 서버에서는 열리지 않습니다. 그것은 지역에서 완벽하게 작동합니다. 내 코드는 아래와 같습니다. 제발 도와주세요웹 사이트 서버에서 Pdf 파일을 열 수 없습니다.

private static void SaveLabel(string labelFileName, byte[] labelBuffer) 
     { 
      // Save label buffer to file 
      FileStream LabelFile = new FileStream(labelFileName, FileMode.Create); 
      LabelFile.Write(labelBuffer, 0, labelBuffer.Length); 
      LabelFile.Close(); 
      // Display label in Acrobat 
      DisplayLabel(labelFileName); 
     } 

    private static void DisplayLabel(string labelFileName) 
     { 
      System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(labelFileName); 
      info.UseShellExecute = true;`enter code here` 
      info.Verb = "open"; 
      System.Diagnostics.Process.Start(info); 
     } 
+0

오류 :

오른쪽 접근 방식은 파일 또는 FileStreamResult 등의 반환 조치 유형이다. 또한 경로는 절대 경로 여야합니다. –

답변

0

이제 웹 사이트에서 작동 할 것입니다. System.Diagnostics.Process.Start는 시스템에서 perticular 프로그램을 실행하는 데 사용됩니다. 서버에서 프로그램을 실행하고 있으므로 브라우저가 아닌 서버에서 파일을 열 수 있습니다. 브라우저에서 pdf 파일을 여는 데 잘못된 승인을 받았습니다. 당신이 점점

public FileStreamResult PDFGenerator() 
{ 
    ///byte[] labelBuffer generate the buffer from pdf 
    MemoryStream ms = new MemoryStream(); 
    ms.Write(labelBuffer, 0, labelBuffer.Length); 
    ms.Position = 0; 
    return new FileStreamResult(ms, "application/pdf"); 
} 
관련 문제