We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Customizing ActionResult Download

I'm adding a feature where double clicking on a file will open it via adding Process.Start in the public ActionResult Download(string downloadInput).  This works correctly, however, I want to remove the actual downloading of the file.  I've tried returning null and returning operation.Download(null, null); but it just redirects to localhost:12345/FileManager/Download.  How do I prevent the Download ActionResult from downloading?

1 Reply

KR Keerthana Rajendran Syncfusion Team November 25, 2019 03:16 AM

Hi William, 
 
Good day to you, 
 
We have checked your reported query about preventing the usual download operation. We suspect your requirement is similar to any of  the below possible cases. 
 
1)     If you don’t want to perform download using toolbar and context menu of file manager component. You can remove the download operations by using toolbarSettings and contextmenuSettings and also customize the operations based on your requirement. Refer the below code snippet. 
     // Toolbar settings customization 
        toolbarSettings: { items: ['NewFolder', 'Upload', 'Cut', 'Copy', 'Paste', 'Delete', 'Rename', 
      'SortBy', 'Refresh', 'Selection', 'View', 'Details' 
        ]}, 
       // Context Menu settings customization 
       contextMenuSettings: { file: ['Open', '|', 'Cut', 'Copy', '|', 'Delete', 'Rename', '|', 'Details'], folder: ['Open', '|', 'Cut', 'Copy', 'Paste', '|', 'Delete', 'Rename', '|', 'Details']} 
 
 
             Refer the sample link below. 
 
2)     If you want to perform custom download operation in both context menu and toolbar. In that case, you can prevent our existing download operations by using toolbarClick() and menuClick() event. In those events, you can filter the events based on the event argument to perform your custom operation.  
 
Refer to the below code snippet. 
   toolbarClick: function(args) { 
          if(args.item.text == "Download") { 
            args.cancel = true; 
            // Perform your custom download operations here 
          } 
        }, 
        menuClick: function(args) { 
          if(args.item.text == "Download" ) { 
             args.cancel = true; 
              // Perform your custom download operations here 
          } 
        } 
 
 
 
In our upcoming Volume 4 release which is expected to be rolled out by the mid of December, we have provided an event beforeDownload() for file manager component. Using that event, you can prevent our download operations and add your custom download operations there. Until then, you can use the above solution for your requirement. 
 
Please let us know, if you have any concerns. 
 
 
Regards, 
Keerthana.  


Loader.
Live Chat Icon For mobile
Up arrow icon