1

この呼び出しを行うと、コンテンツ、正しい MIME タイプ、およびファイル名が返されます。ダウンロードしないだけです。

これを修正する方法について誰かがアイデアを持っている場合は、助けていただければ幸いです。

public FileResult Download()
{
  if (HelperClass.SessionNotExpired(Session))
  {
    string caseNumber = Request.Params["CaseNumber"] as string;
    string fileName = Request.Params["FileName"] as string;
    if (!String.IsNullOrEmpty(caseNumber) && !String.IsNullOrEmpty(fileName))
    {
      Document doc = DropBox.Get(caseNumber, fileName, DocumentServiceRequestCodes.WEB,          (string)Session[HelperClass.EMAIL], (string)Session[HelperClass.PASSWORD]);
      var cd = new System.Net.Mime.ContentDisposition
      {
        // for example foo.bak
        FileName = doc.FileName,

        // always prompt the user for downloading, set to true if you want 
        // the browser to try to show the file inline
        Inline = false,
      };
      Response.AppendHeader("Content-Disposition", cd.ToString());

      return File(doc.Contents, GetMimeType(fileName), fileName);
    }
  }
  return null;
}
4

1 に答える 1

0

コンテンツがストリームの場合、その位置を手動で設定してみますか?

stream.Seek(0, SeekOrigin.Begin);

また

stream.Position = 0;

于 2014-02-18T05:35:00.883 に答える