下面的c# mvc void Action客户端得到什么内容
这是控制器里的代码
public void Video(string pId)
{
//var pId = "HYNB_MP";
var url = GetAerialUrl(pId);
var filePath = Urlconvertorlocal(url);
//这里需要获取全路径 如:D:\project\images\video\products\video.mp4
System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);
if (fileInfo.Exists == true)
{
FileStream fs = new FileStream(filePath, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
//Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileInfo.Name));
Response.AddHeader("Content-Length", "" + fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
}
运行成功后会成功播放视频,但想不通video方法明明时void无返回值的,但为何设置了返回值后还是会正常返回