Returning Multiple Files from MVC Action
June 24, 2014 by Anuraj
.Net ASP.Net ASP.Net MVC CodeProject
Today I faced an issue with ASP.Net MVC, I have to download multiple files as a compressed (zip) file. Initially I thought of using third party component like DotNetZip. Later I used ZipArchive class, which comes with .Net Framework 4.5.
And here is the controller action.
In this implementation I creating text file on the fly and I am reading and using existing files as well.
Note: Following namespaces are required.
You may need to add reference of System.IO.Compression.FileSystem namespace explicitly, without this assembly reference visual studio will not recognize ZipArchive class.
Happy Coding :)
Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub