I am using ASP.NET MVC 2.0 & .NET framework 3.5 sp1.
I have an action that currently takes a viewmodel as it's parameter. The action has a return type of FileResult. It's used in my application to generate 开发者_JS百科a pdf and stream it to the user for download. Is there a way to have this action run asynchronously so multiple files can be streamed back to the user? I know this is ugly, but it's what the user requested and b/c privacy & permission issues, these files exist in memory only so I can't zip them together and stream that down. In essence, the user would click what files he wanted to download and a download dialogue would display for each one.
I'm looking into having my controller inherit AsyncController and implementing the MyActionAsync & MyActionCompleted type methods. Based on my own testing, I'm thinking this can't be done. Can someone verify this?
One request to the server can only return single file. So your code should work just fine as it is - user clicks on a link and get a file, click on another link and gets another file.
If you want to have checkboxes like "file1[], file2[x], file3[x], file4[]" I think you can call click with JavaScript on corresponding links - as long as respons have correct headers it should show file save dialogs. Also user expirience will be strange I think.
精彩评论