我正在使用C# 和 Razor开发MVC3应用程序。当我需要显示一个播放视图时,我遇到了问题。
Play 操作方法用于检索FLV (Flash)文件的路径,然后将其传递给Play View以重现该文件。当我使用应用程序正确return View("Play")
呈现视图时。但是,我需要将路径变量传递给视图,如代码所示。当我这样做时,我收到以下消息:
未找到“播放”视图或其主视图,或没有视图引擎支持搜索到的位置
这是操作方法:
public ActionResult Play(int topicId)
{
var ltopicDownloadLink = _webinarService.FindTopicDownloadLink(topicId);
if (ltopicDownloadLink != null)
{
var path = Server.MapPath("~/App_Data/WebinarRecordings/" + ltopicDownloadLink);
var file = new FileInfo(path);
if (file.Exists)
{
return View("Play", path);
}
}
return RedirectToAction("Index");
}
这是播放视图:
@model System.String
<div id='player'>This div will be replaced by the JW Player.</div>
<script type='text/javascript' src='/FLV Player/jwplayer.js'></script>
<script type='text/javascript'>
var filepath = @Html.Raw(Json.Encode(Model));
jwplayer('player').setup({
'flashplayer':'/FLV Player/player.swf',
'width': '400',
'height': '300',
'file': filepath
});
</script>
我唯一的提示是我在 javascript 中使用模型时犯了一些错误。你能帮帮我吗?
谢谢