我正在尝试使用存储在数据库中并检索并以二进制形式发送的PPTX文件加载iframe:
public void LoadPptx(string courseId)
{
CourseVideo video = Repository.GetCourseVideoStream(courseId);
var bytesinfile = new byte[video.VideoStream.Length];
video.VideoStream.Read(bytesinfile, 0, (int)video.VideoStream.Length);
byte[] buffer = new byte[4096];
ControllerContext.HttpContext.Response.BufferOutput = false;
ControllerContext.HttpContext.Response.ContentType = "text/html";
ControllerContext.HttpContext.Response.AppendHeader("content-length", video.VideoStream.Length.ToString());
video.VideoStream.Seek(0, SeekOrigin.Begin);
ControllerContext.HttpContext.Response.BinaryWrite(bytesinfile);
ControllerContext.HttpContext.Response.End();
}
页面中的iframe是:
<iframe id="iframepp" width="200" height="200" src="@Url.Action("LoadPptx", "OLT", new { courseId = Model.ID })" type = "text/html"></iframe>
最初是为了显示视频而制作的,现在仍然如此,但是我正在尝试使其适应于在iframe中显示PPTX文件。
如果我将iframe中的类型输入到application / vnd.openxmlformats-officedocument.presentationml.presentation,我会得到相同的结果,但它表示它是pptx文件。