我的网站上有一个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文件?
像这样创建一个Action:
public ActionResult Stream(string mp3){
byte[] file=readFile(mp3);
return File(file,"audio/mpeg");
}
Run Code Online (Sandbox Code Playgroud)
函数readFile应该从文件中读取MP3并将其作为byte []返回.
| 归档时间: |
|
| 查看次数: |
9090 次 |
| 最近记录: |