1

Folder structure... /albums/test.zip

I have a button on web page Download Button

On the button click, the test.zip that is inside albums should be downloaded.

I am not needing to build zip, on button click, the available zip should get downloaded.

Thats it. I am using ASP.Net MVC

Kgn-web
  • 7,047
  • 24
  • 95
  • 161
  • possible duplicate of [Returning a file to View/Download in MVC](http://stackoverflow.com/questions/5826649/returning-a-file-to-view-download-in-mvc) – AaronLS Jun 29 '15 at 17:43
  • Here's another way: http://stackoverflow.com/a/27477785/84206 – AaronLS Jun 29 '15 at 17:43
  • You could also just simply add a file link to your Zip file in your html. http://stackoverflow.com/a/18246357/1729859 – mituw16 Jun 29 '15 at 17:45
  • @mituw.. I will not be knowing the file name in advance..I just know that the album folder has one zip file...and that zip file is created on fly – Kgn-web Jun 29 '15 at 19:33
  • @Chetan I see. You didn't specify that in your post. What you would need to do in your scenario then is have C# loop over all the files in your directory, and then present them as file links to your user, or open the file into a memory stream and send it back in your response headers. – mituw16 Jun 29 '15 at 20:14

1 Answers1

0

It's as simple as this:

<a href="~/albums/test.zip">
    <img src="~/Images/download.png" alt="Download zip file." />
</a>

The download will start when the user clicks the image.

Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
  • in my scenario, I know that albums folder has a zip file but what will be the name of the zip file that will not be knowing in advance. – Kgn-web Jun 29 '15 at 19:20
  • 1
    @Chetan Fair enough. Consider asking a new question based on what you've learned from the answers and comments to your first question. I find that my pattern is often initial problem > question > answer > new question > answer > new question > answer that solves the initial problem. – Shaun Luttin Jun 29 '15 at 19:36