views:

439

answers:

1

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?

+2  A: 

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.

tvanfosson
thanks! You've set me straight concerting generating the link. but.. ContentResult only allows me to set a string as the content to return.. I actually want to stream out the swf once the action is called. what should that action method look like?
Travis Laborde
My bad -- just don't set a FileDownloadName on your FileResult and it won't set the Content-Disposition header. So, the FileStreamResult is correct.
tvanfosson