如何从ASP.NET MVC控制器动作流式传输MP3

gon*_*ong 4 asp.net-mvc view

我的网站上有一个mp3文件.我想将其输出为视图.在我的控制器中我有:

public ActionResult Stream()
{
        string file = 'test.mp3';
        this.Response.AddHeader("Content-Disposition", "test.mp3");
        this.Response.ContentType = "audio/mpeg";

        return View();
}
Run Code Online (Sandbox Code Playgroud)

但是我如何返回mp3文件?

Car*_*any 9

像这样创建一个Action:

public ActionResult Stream(string mp3){
    byte[] file=readFile(mp3);
    return File(file,"audio/mpeg");
}
Run Code Online (Sandbox Code Playgroud)

函数readFile应该从文件中读取MP3并将其作为byte []返回.