我的FileContentResult返回哪种内容类型有关系吗?

时间:2018-08-13 01:49:32

标签: c# asp.net-core download mime-types content-type

我需要在我的操作方法中返回一个FileContentResult,这可能有很多原因。 pdf,图像,excel电子表格等...

我如何确定要返回的内容类型以及客户端(浏览器)上要检查/使用的内容/ MIME类型?如果没有JavaScript,那么正确获取MIME /内容类型有多重要。

MIME和内容类型是同一回事,对吧?

public IActionResult Download(string documentName,string filename){

string filePath = path.Combine(Directory.GetCurrentDirectory(),"Uploads",$"{documentName}_{fileName}")
byte[] fileContents = System.IO.File.ReadAllBytes(filePath);
return File(fileContents,"What goes here?");

0 个答案:

没有答案