开发者

JWPlayer in MVC3 application does not work when deployed in IIS 7.5

开发者 https://www.devze.com 2023-03-13 07:14 出处:网络
I am developing an ASP.NET MVC3 application with c# and Razor. I created a page where the user can play video files which are located in the application directory tree.

I am developing an ASP.NET MVC3 application with c# and Razor. I created a page where the user can play video files which are located in the application directory tree.

When I tested the application locally it was working correctly, when I deployed it in MS Server 2008 with IIS 7.5 everything worked fine except the video streaming.

The page does not even display the player and this let me think that the application cannot find the Javascript file needed to load the player. I tried all the types of URL encoding, I set different types of permission but that did not solve the problem. Hereby I post the code of the View:

 @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>

Where Model is a string rep开发者_如何学Goresenting the path of the video file. May anybody help me with this issue?

Thanks

Francesco


Instead of:

@Url.Content("/FLV Player/player.swf")

You should:

@Url.Content("~/FLV Player/player.swf")

Notice the ~. This is what you are missing in both your urls. Always put a ~ in the beginning when you are using the Url.Content helper. It will represent the virtual directory name.

0

精彩评论

暂无评论...
验证码 换一张
取 消