从Azure Blob打开.docx文件

时间:2016-10-31 20:48:45

标签: c# asp.net-mvc azure azure-blob-storage

我在页面中显示文件列表,我想在点击FileName时在浏览器中显示该文件。文件将始终是文档(pdftxt.docx)。一切正常,除非文件具有.docx扩展名,当文件具有.docx扩展名时,浏览器会尝试使用WinRar打开它。这是使用Internet Explorer作为浏览器,当我使用谷歌浏览器并尝试打开.docx文件时,浏览器中的选项卡会打开,但有任何类型的符号,如:PK!ߤÒlZ [Content_Types].xml ¢( ´”ËnÂ0E÷•ú‘·Ub袪*‹>–-Ré{Vý’Ǽþ¾QU‘ l"%3÷Þ3VƃÑÚšl µw%ë=–“^i7+Ù×ä-d&á”0ÞAÉ6€l4¼½L60#µÃ’ÍS Oœ£œƒXøŽ*•V$z3„ü3à÷½Þ—Þ%p)Oµ^ “²×5}nH"dÙsÓXg•L„' ‰ê|éÔŸ“|-PrÛƒsðŽ?〜 and the same thing happens when I try to open a。pdf using Google Chrome。 这是我的行动,我只想在点击名称时在浏览器中打开文档,它们存储在Azure Blob ...

  public ActionResult OpenFile(string fileName, int noteId)
            {
    Response.AddHeader("Content-Disposition", MimeMapping.GetMimeMapping(fileName) + fileName);
container.GetBlobReference(String.Format("{0}/{1}", noteId, Path.GetFileName(fileName))).DownloadToStream(Response.OutputStream);
     return new EmptyResult();
    }

0 个答案:

没有答案