c# - "Download all" option available to user using Html.ActionLink -
quick question, want give user option download attachments details view.
this works single attachment...
@foreach (var file in model.attachments) { <div class="margin-bottom-25"> <a href="?"> <img src="~/images/pdf.gif" /></a> <div> <strong>@file.filename</strong> <span>@file.filesizekb kb</span> @html.actionlink("download", "viewdocument", new { messageid = file.messageid.tostring("n"), documentid = file.id.tostring("n"), documenttype = file.attachmenttype.tostring(), download = true }) </div> </div> }
however want give user ability select "download all" link....? sounds straight forward, tried putting foreach within link , it's none runner.....any ideas appreciated ? (asp.net mvc 4 application, using razor2 views)
iterate on documents , construct zip file (best supported) subsequently send user.
just implement different action on controller, call downloadall
. loop on files in model.attachments, , add them zip package return, download
on viewdocument
.
take @ ziparchive
http://msdn.microsoft.com/en-us/library/hh137435 if use .net 4.5 or otherwise zippackage
. see how zip file in c#, using no 3rd-party apis? more information too.
Comments
Post a Comment