我将视频数据存储在数据库中,并希望在我的页面中播放。我像这样制作自定义处理程序(FileHandler.ashx)
public void ProcessRequest(HttpContext context)
{
int id;
if (context.Request.QueryString["FileId"] == null || !Int32.TryParse(context.Request.QueryString["FileId"], out id))
return;
var file = lnxFile.Get(id);
string fileName = file.Name + file.Extension;
context.Response.Clear();
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
context.Response.BinaryWrite(file.Data);
context.Response.End();
context.Response.Flush();
}
并像这样使用了html5的视频标签
<video id="jwplayer_placeholder" width="320" height="240" controls>
<source src="<%= "/CMS/Common/FileHandler.ashx?FileId=" + id %>" type="video/mp4">
</video>
但它什么也没玩。谁能解释一下原因?