Travis Laborde
Travis Laborde

Reputation: 1333

how to display Flash (swf) content in ASP.NET MVC

In our WebForms apps we serve flash via simple anchor tags like so:

<a href="whatever.swf" class="something" params="with, height, yadda, bang">See It</a>

Now, I'm wanting to move that A tag into a call to a Controller/Action using an Html.ActionLink like so:

Html.ActionLink("See It", "DeliverFlash", new {fileName="whatever.swf"})

Then in the controller I'm using a FileStreamResult to push it out....

That "works" in that the flash goes out BUT....

1) It only prompts the user to download the swf I'd like it to just show it like the original implementation does.

2) I have not yet figured out how to pass along those extra parameters of class and params.

Can anyone help please?

Upvotes: 0

Views: 2635

Answers (1)

tvanfosson
tvanfosson

Reputation: 532435

Make sure that when you create the FileResult, that you don't set the FileDownloadName property or it will add a Content-Disposition header to specify it as an attachment. See the source code at: http://www.codeplex.com/aspnet. To set the extra parameters, you simply need to use a signature that includes the html options.

<%= Html.ActionLink( "See It", "DeliverFlash",
                     new { fileName = "whatever.swf" },
                     new { 
                           @class = "something",
                           @params = "width, height, yadda, bang"
                         } ) %>

Note the @ in front of class and params as they are C# keywords.

Upvotes: 2

Related Questions