0

I am currently trying to display an SWF file using the following syntax src="@Html.C1().MediaUrl(b.SWFFile)"

but the path that is being output is

src="/media/0f923295-713b-418d-afbf-17675cdb6d9e/Banner Ads/Flash/728x90_swf"

Why is Composite C1 changing the file extension to _swf? Am I using an incorrect function to reference the media file?

TGuimond
  • 5,475
  • 6
  • 41
  • 51

1 Answers1

1

There are 2 reasons of not using extensions in build-in media url-s:

1) if you're running IIS6 or IIS7 classic mode, IIS may not channel the request to ASP.NET (because of the extension) and therefore C1 won't be able to serve it.

2) In the default settings of IIS7 there are a lot of extensions, presence of which makes IIS return 404 (such as .config, .master and .cs).

I guess you have a problem of flash player not playing the file, the issue is reported here http://compositec1.codeplex.com/workitem/1379 and it will likely be addresses in the next release.

For now I recommend to use the following code for generating flash urls as a workaround

protected string GetMediaUrl(string mediaPath)
{
    string[] parts = mediaPath.Split(new[] { ':' });

    string mediaStore = parts[0];
    Guid mediaId = new Guid(parts[1]);

    string mediaUrl = MediaUrls.BuildUrl(new MediaUrlData { MediaStore = mediaStore, MediaId = mediaId, QueryParameters = new NameValueCollection() },
                                         UrlKind.Public);

    // Temporary fix, allows media player to receive a nice url with an extension
    return mediaUrl.Replace("_jpg", ".jpg").Replace("_mov", ".mov").Replace("_m4v", ".m4v").Replace("_swf", ".swf");
}
Pauli Østerø
  • 6,878
  • 2
  • 31
  • 48