问题描述
|
我正在使用c#和Razor开发ASP.NET MVC3应用程序。我创建了一个页面,用户可以在其中播放位于应用程序目录树中的视频文件。
当我在本地测试该应用程序时,它可以正常工作,当我在具有IIS 7.5的MS Server 2008中部署该应用程序时,除了视频流以外,其他所有功能都正常运行。
该页面甚至没有显示播放器,这让我认为应用程序找不到加载播放器所需的Javascript文件。我尝试了所有类型的URL编码,我设置了不同类型的权限,但这不能解决问题。我在此发布视图的代码:
@model System.String
@{
ViewBag.Title = \"Play\";
}
<h2>Playing Topic Video</h2>
<div id=\'player\'>This div will be replaced by the JW Player.</div>
<script type=\'text/javascript\' src=\'@Url.Content(\"/FLV Player/jwplayer.js\")\'></script>
<script type=\'text/javascript\'>
var filepath = @Html.Raw(Json.Encode(Model));
jwplayer(\'player\').setup({
\'flashplayer\':\'@Url.Content(\"/FLV Player/player.swf\")\',\'width\': \'400\',\'height\': \'300\',\'file\': filepath
});
</script>
其中Model是代表视频文件路径的字符串。有人可以帮我解决这个问题吗?
谢谢
弗朗切斯科
解决方法
代替:
@Url.Content(\"/FLV Player/player.swf\")
你应该:
@Url.Content(\"~/FLV Player/player.swf\")
注意the3ѭ。这是您在两个URL中都缺少的内容。使用Url.Content
助手时,请始终在开头放置~
。它将代表虚拟目录名称。