Download file in mvc 4 razor






















Clear ; context. TransmitFile context. MapPath System. End ; the above example uses a pdf file as the file being downloaded. Friday, March 8, AM. Thursday, March 7, PM. User posted An option not metioned above: If you wish to have full control of the download process, you can create a custom generic handler that will serve the file to the user. User posted Thanks for your answers. I already tried somethink like this: Response.

Clear ; Response. TransmitFile System. Combine setupDirectory, setupName ; Response. Compression; namespace SatyaMultipleZipDownload. GetFiles Server. Add Path. Exists Server. Delete Server. Open Server. CreateEntryFromFile Server. Dispose ; return File Server. IO namespace to retrieve a list of files in the Images folder.

It then adds those files to a List. View All. Satyaprakash Samantaray Updated date Aug 10, Steps to be followed. Code Ref. Notice that GetFiles returns the full path and file name for all the files. While adding these files to the generic List, we pick only the file name. This is done using the GetFileName method of Path class.

The List is then passed to the Index View as its model. Next, add another action - ProcessForm - to the HomeController. The ProcessForm action does the job of creating the zip file. Compression namespace and hence you need to add a reference to System. The ProcessForm action receives a List of strings. This list is nothing but a list of values of the checkboxes displayed on the page. The ASP.

The code checks whether a file named Bundle. Learn more. Asked 7 years, 2 months ago. Active 3 years, 6 months ago. Viewed 34k times. I have a MVC-application. And I want to download a pdf. Improve this question. Dan Is Fiddling By Firelight 5, 16 16 gold badges 74 74 silver badges bronze badges. What is the problem? Add a comment.

Active Oldest Votes. Possible solution - provide form method and controller name: using Html. Create Path. File "MyFile. Improve this answer. Dmytro Dmytro I could not take files from that folder. So I had to move my file to another folder.



0コメント

  • 1000 / 1000