Html 如何在iframe中嵌入视频
使用HTML5视频支持非常令人惊讶,但在IE版本中不起作用,所以我不喜欢它 我正在使用MVC4 Razor视图引擎进行开发 我提出了这个问题- 虽然我直接从youtube嵌入视频,但效果很好。但是当我上传一个视频,然后通过Html 如何在iframe中嵌入视频,html,asp.net-mvc-4,iframe,Html,Asp.net Mvc 4,Iframe,使用HTML5视频支持非常令人惊讶,但在IE版本中不起作用,所以我不喜欢它 我正在使用MVC4 Razor视图引擎进行开发 我提出了这个问题- 虽然我直接从youtube嵌入视频,但效果很好。但是当我上传一个视频,然后通过@Model.FilePath显示它时,它甚至没有在那里显示iframe。这条路是正确的 控制器- [HttpPost] public ActionResult Index(HttpPostedFileBase file, SystemUser user)
@Model.FilePath
显示它时,它甚至没有在那里显示iframe。这条路是正确的
控制器-
[HttpPost]
public ActionResult Index(HttpPostedFileBase file, SystemUser user)
{
if (file != null && file.ContentLength > 0)
{
string path = Server.MapPath("~/Logo/");
file.SaveAs(path + file.FileName);
string filePath = "/Logo/" + Path.GetFileName(file.FileName);
string Extension = Path.GetExtension(file.FileName);
var scope = (from u in dv.SystemUsers
where u.UserId == this.LoggedInUser.UserId
select u).FirstOrDefault();
scope.FilePath = filePath;
scope.FileName = file.FileName;
dv.SystemUsers.GetModifiedMembers(scope);
dv.SubmitChanges();
return RedirectToAction("userprofile", "User");
}
return View();
}
@model MvcApplication8.Models.SystemUser
<h2>
UserProfile</h2>
<iframe width="560" height="315" src="@Model.FilePath" frameborder="0" ></iframe>
/Logo/video-2012-12-08-21-31-56.mp4
查看-
[HttpPost]
public ActionResult Index(HttpPostedFileBase file, SystemUser user)
{
if (file != null && file.ContentLength > 0)
{
string path = Server.MapPath("~/Logo/");
file.SaveAs(path + file.FileName);
string filePath = "/Logo/" + Path.GetFileName(file.FileName);
string Extension = Path.GetExtension(file.FileName);
var scope = (from u in dv.SystemUsers
where u.UserId == this.LoggedInUser.UserId
select u).FirstOrDefault();
scope.FilePath = filePath;
scope.FileName = file.FileName;
dv.SystemUsers.GetModifiedMembers(scope);
dv.SubmitChanges();
return RedirectToAction("userprofile", "User");
}
return View();
}
@model MvcApplication8.Models.SystemUser
<h2>
UserProfile</h2>
<iframe width="560" height="315" src="@Model.FilePath" frameborder="0" ></iframe>
/Logo/video-2012-12-08-21-31-56.mp4
使用
处理图像而不是视频时,效果非常好
iframe嵌入出了什么问题?如果他找到了你的url,你是否在寻找网络(例如devTool F12 Chrome)?保存视频后,您能阅读吗 你可以试试看
@Url.Content("~/Logo/video-2012-12-08-21-31-56.mp4")
或
更新
您可以这样做:
@Url.Content(Model.Filepath)
这工作对我来说很好
或者示例(jsfiddle)感谢您在这方面的工作,但这不仅仅是一个静态视频路径。我正在保存路径,然后通过
@Model显示它。Filepath
仍在挣扎,我得到了Filepath,但它欢迎我,因为无法解决服务器的DNS地址
错误。