When you use the overload File(byte[] contents, string mimeType, string fileName) a Content-Disposition header is automatically added to the response with attachment, so you don't need to add it a second time. For inline you could use the following overload File(byte[] contents, string mimeType) and manually add the Content-Disposition header:[ActionName("display-file")]public virtual ActionResult DisplayFile(Guid fileId){ var file = _repos.GetFileInfo(fileId); var cd = new ContentDisposition { Inline = true, FileName = file.Name }; Response.AddHeader("Content-Disposition", cd.ToString()); return File(file.Content, file.MimeType);}[ActionName("download-file")]public virtual ActionResult DownloadFile(Guid fileId){ var file = _repos.GetFileInfo(fileId); return File(file.Content, file.MimeType, file.Name);} 这篇关于如何使用 MVC3 FileContentResult 避免重复的内容处置标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
05-17 01:11