Provide a link to download without creating a file on the server

asp.net-mvc, asp.net-mvc-3, c#, dotnetzip, zip

Solution

You don't use `return View()` but something like:

return File(myMemoryStream,                           // zipped data
    System.Net.Mime.MediaTypeNames.Application.Zip,   // "application/zip"
    "default.zip");                                   // suggested download name

There are a few overloads available.

The `Controller.File()` and `Controller.View()` helper functions both return types derived from `ActionResult`.

Problem

I want to create a file and give it to download without putting itself on the server. ``` public ActionResult DownloadZip(Guid id){ using (ZipFile zip = new ZipFile()) { zip.Password = "123456!"; // GenareteString(); // add string to file // save zip //return zip to user } return View(); } ``` how to do it I use DotNetZip

Original source