【发布时间】:2014-11-04 02:26:58
【问题描述】:
我正在使用 FileResult 在我的网站中显示文件,如下所示:
public ActionResult GetSwf(long id = 0)
{
if (id <= 0) return null;
Attachment attachment = Service.GetAttachmentById(id);
if (attachment == null) return null;
string filename = attachment.Name;
string mimeType = "application/x-shockwave-flash";
string absoluteFilePath = UploadedPaths.GetAbsolutePath(attachment.Path);
return File(absoluteFilePath, mimeType, filename);
}
它不适用于以下标签,浏览器将下载文件而不是显示它!
<object type="application/x-shockwave-flash" width="220" height="166" data="File/GetSwf/1232" class="flash-object" data-name="ads-file"></object>
出了什么问题,我该如何解决?
【问题讨论】:
-
您检查过浏览器插件吗?安装flash插件并重新检查get.adobe.com/flashplayer
-
我有最新版本的 chrome 38 Flash Player。
-
尝试将 Response 标头的 Content-Disposition 属性模式设置为“内联”,看看是否有区别。
-
这种行为(下载文件)在您返回 FileResult 时是正常的...您可以返回 json(new {FilePath=""});
标签: c# asp.net-mvc fileresult